aboutsummaryrefslogtreecommitdiff
path: root/ltable.c
diff options
context:
space:
mode:
Diffstat (limited to 'ltable.c')
-rw-r--r--ltable.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/ltable.c b/ltable.c
index 0e271e8c..d91ed36c 100644
--- a/ltable.c
+++ b/ltable.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltable.c,v 1.49 2000/06/28 17:03:56 roberto Exp roberto $ 2** $Id: ltable.c,v 1.50 2000/06/30 14:35:17 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*/
@@ -154,19 +154,22 @@ static void setnodevector (lua_State *L, Hash *t, lint32 size) {
154 ttype(&t->node[i].key) = ttype(&t->node[i].val) = TAG_NIL; 154 ttype(&t->node[i].key) = ttype(&t->node[i].val) = TAG_NIL;
155 t->node[i].next = NULL; 155 t->node[i].next = NULL;
156 } 156 }
157 L->nblocks += gcsize(L, size) - gcsize(L, t->size);
157 t->size = size; 158 t->size = size;
158 t->firstfree = &t->node[size-1]; /* first free position to be used */ 159 t->firstfree = &t->node[size-1]; /* first free position to be used */
159 L->nblocks += gcsize(L, size);
160} 160}
161 161
162 162
163Hash *luaH_new (lua_State *L, int size) { 163Hash *luaH_new (lua_State *L, int size) {
164 Hash *t = luaM_new(L, Hash); 164 Hash *t = luaM_new(L, Hash);
165 setnodevector(L, t, luaO_power2(size));
166 t->htag = TagDefault; 165 t->htag = TagDefault;
167 t->next = L->roottable; 166 t->next = L->roottable;
168 L->roottable = t; 167 L->roottable = t;
169 t->marked = 0; 168 t->marked = 0;
169 t->size = 0;
170 L->nblocks += gcsize(L, 0);
171 t->node = NULL;
172 setnodevector(L, t, luaO_power2(size));
170 return t; 173 return t;
171} 174}
172 175
@@ -204,7 +207,6 @@ static void rehash (lua_State *L, Hash *t) {
204 setnodevector(L, t, oldsize/2); 207 setnodevector(L, t, oldsize/2);
205 else 208 else
206 setnodevector(L, t, oldsize); 209 setnodevector(L, t, oldsize);
207 L->nblocks -= gcsize(L, oldsize);
208 for (i=0; i<oldsize; i++) { 210 for (i=0; i<oldsize; i++) {
209 Node *old = nold+i; 211 Node *old = nold+i;
210 if (ttype(&old->val) != TAG_NIL) 212 if (ttype(&old->val) != TAG_NIL)