aboutsummaryrefslogtreecommitdiff
path: root/ltable.c
diff options
context:
space:
mode:
Diffstat (limited to 'ltable.c')
-rw-r--r--ltable.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/ltable.c b/ltable.c
index 4ac0caab..f0adc627 100644
--- a/ltable.c
+++ b/ltable.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltable.c,v 1.4 1997/10/23 16:26:37 roberto Exp roberto $ 2** $Id: ltable.c,v 1.5 1997/10/24 17:17:24 roberto Exp roberto $
3** Lua tables (hash) 3** Lua tables (hash)
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -9,6 +9,7 @@
9#include "lauxlib.h" 9#include "lauxlib.h"
10#include "lmem.h" 10#include "lmem.h"
11#include "lobject.h" 11#include "lobject.h"
12#include "lstate.h"
12#include "ltable.h" 13#include "ltable.h"
13#include "lua.h" 14#include "lua.h"
14 15
@@ -24,9 +25,6 @@
24#define TagDefault LUA_T_ARRAY; 25#define TagDefault LUA_T_ARRAY;
25 26
26 27
27GCnode luaH_root = {NULL, 0};
28
29
30 28
31static long int hashindex (TObject *ref) 29static long int hashindex (TObject *ref)
32{ 30{
@@ -95,7 +93,7 @@ void luaH_free (Hash *frees)
95{ 93{
96 while (frees) { 94 while (frees) {
97 Hash *next = (Hash *)frees->head.next; 95 Hash *next = (Hash *)frees->head.next;
98 luaO_nblocks -= gcsize(frees->nhash); 96 L->nblocks -= gcsize(frees->nhash);
99 hashdelete(frees); 97 hashdelete(frees);
100 frees = next; 98 frees = next;
101 } 99 }
@@ -110,8 +108,8 @@ Hash *luaH_new (int nhash)
110 nhash(t) = nhash; 108 nhash(t) = nhash;
111 nuse(t) = 0; 109 nuse(t) = 0;
112 t->htag = TagDefault; 110 t->htag = TagDefault;
113 luaO_insertlist(&luaH_root, (GCnode *)t); 111 luaO_insertlist(&(L->roottable), (GCnode *)t);
114 luaO_nblocks += gcsize(nhash); 112 L->nblocks += gcsize(nhash);
115 return t; 113 return t;
116} 114}
117 115
@@ -145,7 +143,7 @@ static void rehash (Hash *t)
145 if (ttype(ref(n)) != LUA_T_NIL && ttype(val(n)) != LUA_T_NIL) 143 if (ttype(ref(n)) != LUA_T_NIL && ttype(val(n)) != LUA_T_NIL)
146 *node(t, present(t, ref(n))) = *n; /* copy old node to luaM_new hash */ 144 *node(t, present(t, ref(n))) = *n; /* copy old node to luaM_new hash */
147 } 145 }
148 luaO_nblocks += gcsize(t->nhash)-gcsize(nold); 146 L->nblocks += gcsize(t->nhash)-gcsize(nold);
149 luaM_free(vold); 147 luaM_free(vold);
150} 148}
151 149