diff options
Diffstat (limited to 'ltable.c')
-rw-r--r-- | ltable.c | 25 |
1 files changed, 11 insertions, 14 deletions
@@ -1,10 +1,9 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltable.c,v 1.23 1999/08/16 20:52:00 roberto Exp roberto $ | 2 | ** $Id: ltable.c,v 1.24 1999/09/22 14:38:45 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 | */ |
6 | 6 | ||
7 | #include <stdlib.h> | ||
8 | 7 | ||
9 | #include "lauxlib.h" | 8 | #include "lauxlib.h" |
10 | #include "lmem.h" | 9 | #include "lmem.h" |
@@ -69,17 +68,6 @@ Node *luaH_present (const Hash *t, const TObject *key) { | |||
69 | } | 68 | } |
70 | 69 | ||
71 | 70 | ||
72 | void luaH_free (Hash *frees) { | ||
73 | while (frees) { | ||
74 | Hash *next = (Hash *)frees->head.next; | ||
75 | L->nblocks -= gcsize(frees->nhash); | ||
76 | luaM_free(nodevector(frees)); | ||
77 | luaM_free(frees); | ||
78 | frees = next; | ||
79 | } | ||
80 | } | ||
81 | |||
82 | |||
83 | static Node *hashnodecreate (int nhash) { | 71 | static Node *hashnodecreate (int nhash) { |
84 | Node *const v = luaM_newvector(nhash, Node); | 72 | Node *const v = luaM_newvector(nhash, Node); |
85 | int i; | 73 | int i; |
@@ -96,12 +84,21 @@ Hash *luaH_new (int nhash) { | |||
96 | nhash(t) = nhash; | 84 | nhash(t) = nhash; |
97 | nuse(t) = 0; | 85 | nuse(t) = 0; |
98 | t->htag = TagDefault; | 86 | t->htag = TagDefault; |
99 | luaO_insertlist(&(L->roottable), (GCnode *)t); | 87 | t->next = L->roottable; |
88 | L->roottable = t; | ||
89 | t->marked = 0; | ||
100 | L->nblocks += gcsize(nhash); | 90 | L->nblocks += gcsize(nhash); |
101 | return t; | 91 | return t; |
102 | } | 92 | } |
103 | 93 | ||
104 | 94 | ||
95 | void luaH_free (Hash *t) { | ||
96 | L->nblocks -= gcsize(t->nhash); | ||
97 | luaM_free(nodevector(t)); | ||
98 | luaM_free(t); | ||
99 | } | ||
100 | |||
101 | |||
105 | static int newsize (Hash *t) { | 102 | static int newsize (Hash *t) { |
106 | Node *const v = t->node; | 103 | Node *const v = t->node; |
107 | const int size = nhash(t); | 104 | const int size = nhash(t); |