diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-05-11 15:57:19 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-05-11 15:57:19 -0300 |
commit | b803c0600eb20f3d4e47fd7a9ceecb096abcd3c6 (patch) | |
tree | e2cb54f144b403cea94d5775bc322bcc9feb7d7d | |
parent | 8ac0bbf64b93a672c6f29c2d96d22d727035e9ed (diff) | |
download | lua-b803c0600eb20f3d4e47fd7a9ceecb096abcd3c6.tar.gz lua-b803c0600eb20f3d4e47fd7a9ceecb096abcd3c6.tar.bz2 lua-b803c0600eb20f3d4e47fd7a9ceecb096abcd3c6.zip |
details
-rw-r--r-- | lgc.c | 8 | ||||
-rw-r--r-- | ltable.c | 19 |
2 files changed, 10 insertions, 17 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lgc.c,v 1.48 2000/05/08 19:32:53 roberto Exp roberto $ | 2 | ** $Id: lgc.c,v 1.49 2000/05/10 16:33:20 roberto Exp roberto $ |
3 | ** Garbage Collector | 3 | ** Garbage Collector |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -62,7 +62,7 @@ static void closuremark (lua_State *L, Closure *f) { | |||
62 | } | 62 | } |
63 | 63 | ||
64 | 64 | ||
65 | static void hashmark (lua_State *L, Hash *h) { | 65 | static void tablemark (lua_State *L, Hash *h) { |
66 | if (!h->marked) { | 66 | if (!h->marked) { |
67 | int i; | 67 | int i; |
68 | h->marked = 1; | 68 | h->marked = 1; |
@@ -99,7 +99,7 @@ static int markobject (lua_State *L, TObject *o) { | |||
99 | strmark(L, tsvalue(o)); | 99 | strmark(L, tsvalue(o)); |
100 | break; | 100 | break; |
101 | case TAG_TABLE: | 101 | case TAG_TABLE: |
102 | hashmark(L, avalue(o)); | 102 | tablemark(L, avalue(o)); |
103 | break; | 103 | break; |
104 | case TAG_LCLOSURE: case TAG_LMARK: | 104 | case TAG_LCLOSURE: case TAG_LMARK: |
105 | protomark(L, clvalue(o)->f.l); | 105 | protomark(L, clvalue(o)->f.l); |
@@ -206,7 +206,7 @@ static void collectstring (lua_State *L, int limit) { | |||
206 | 206 | ||
207 | static void markall (lua_State *L) { | 207 | static void markall (lua_State *L) { |
208 | travstack(L); /* mark stack objects */ | 208 | travstack(L); /* mark stack objects */ |
209 | hashmark(L, L->gt); /* mark global variable values and names */ | 209 | tablemark(L, L->gt); /* mark global variable values and names */ |
210 | travlock(L); /* mark locked objects */ | 210 | travlock(L); /* mark locked objects */ |
211 | luaT_travtagmethods(L, markobject); /* mark tag methods */ | 211 | luaT_travtagmethods(L, markobject); /* mark tag methods */ |
212 | } | 212 | } |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltable.c,v 1.40 2000/04/25 16:55:09 roberto Exp roberto $ | 2 | ** $Id: ltable.c,v 1.41 2000/05/08 19:32:53 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 | */ |
@@ -122,20 +122,13 @@ int luaH_pos (lua_State *L, const Hash *t, const TObject *key) { | |||
122 | } | 122 | } |
123 | 123 | ||
124 | 124 | ||
125 | 125 | static void setnodevector (lua_State *L, Hash *t, int size) { | |
126 | static Node *hashnodecreate (lua_State *L, int nhash) { | ||
127 | Node *v = luaM_newvector(L, nhash, Node); | ||
128 | int i; | 126 | int i; |
129 | for (i=0; i<nhash; i++) { | 127 | t->node = luaM_newvector(L, size, Node); |
130 | ttype(&v[i].key) = ttype(&v[i].val) = TAG_NIL; | 128 | for (i=0; i<size; i++) { |
131 | v[i].next = NULL; | 129 | ttype(&t->node[i].key) = ttype(&t->node[i].val) = TAG_NIL; |
130 | t->node[i].next = NULL; | ||
132 | } | 131 | } |
133 | return v; | ||
134 | } | ||
135 | |||
136 | |||
137 | static void setnodevector (lua_State *L, Hash *t, int size) { | ||
138 | t->node = hashnodecreate(L, size); | ||
139 | t->size = size; | 132 | t->size = size; |
140 | t->firstfree = &t->node[size-1]; /* first free position to be used */ | 133 | t->firstfree = &t->node[size-1]; /* first free position to be used */ |
141 | L->nblocks += gcsize(L, size); | 134 | L->nblocks += gcsize(L, size); |