diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1999-10-04 15:51:04 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1999-10-04 15:51:04 -0200 |
commit | 4343420d4d559a7d4cdacdbc1fd61552dcf59f04 (patch) | |
tree | 57e0bdd41e2f3a4ab70d3150022569751e3d02ad /ltable.c | |
parent | 1f7103e05d01a6a4c300a73bcfc8d9b17b2c20a4 (diff) | |
download | lua-4343420d4d559a7d4cdacdbc1fd61552dcf59f04.tar.gz lua-4343420d4d559a7d4cdacdbc1fd61552dcf59f04.tar.bz2 lua-4343420d4d559a7d4cdacdbc1fd61552dcf59f04.zip |
simplified version of `gc' tag method (only for userdata now).
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); |