aboutsummaryrefslogtreecommitdiff
path: root/lgc.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-06-15 17:36:57 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-06-15 17:36:57 -0300
commit8e586c13fcf3066886a7edd69011304eaad57a2b (patch)
tree417c2102ba8c4d693c49a2df839612d371eded50 /lgc.c
parenteadf2aaaffa7a35e7f67b150ce0d57f2c17b9231 (diff)
downloadlua-8e586c13fcf3066886a7edd69011304eaad57a2b.tar.gz
lua-8e586c13fcf3066886a7edd69011304eaad57a2b.tar.bz2
lua-8e586c13fcf3066886a7edd69011304eaad57a2b.zip
cleaner way to ensure alignment for strings and userdata
Diffstat (limited to 'lgc.c')
-rw-r--r--lgc.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/lgc.c b/lgc.c
index baaca9a7..de5998e3 100644
--- a/lgc.c
+++ b/lgc.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lgc.c,v 1.104 2001/06/13 18:51:20 roberto Exp roberto $ 2** $Id: lgc.c,v 1.105 2001/06/15 19:17:33 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*/
@@ -27,7 +27,7 @@ typedef struct GCState {
27 27
28 28
29/* mark a string; marks larger than 1 cannot be changed */ 29/* mark a string; marks larger than 1 cannot be changed */
30#define strmark(s) {if ((s)->marked == 0) (s)->marked = 1;} 30#define strmark(s) {if ((s)->tsv.marked == 0) (s)->tsv.marked = 1;}
31 31
32 32
33 33
@@ -184,7 +184,7 @@ static void markall (lua_State *L) {
184static int hasmark (int tt, Value *v) { 184static int hasmark (int tt, Value *v) {
185 switch (tt) { 185 switch (tt) {
186 case LUA_TSTRING: 186 case LUA_TSTRING:
187 return v->ts->marked; 187 return v->ts->tsv.marked;
188 case LUA_TUSERDATA: 188 case LUA_TUSERDATA:
189 return ismarkedudata(v->u); 189 return ismarkedudata(v->u);
190 case LUA_TTABLE: 190 case LUA_TTABLE:
@@ -274,12 +274,12 @@ void luaC_collectudata (lua_State *L) {
274 while ((curr = *p) != NULL) { 274 while ((curr = *p) != NULL) {
275 if (ismarkedudata(curr)) { 275 if (ismarkedudata(curr)) {
276 switchudatamark(curr); /* unmark */ 276 switchudatamark(curr); /* unmark */
277 p = &curr->next; 277 p = &curr->uv.next;
278 } 278 }
279 else { /* collect */ 279 else { /* collect */
280 int tag = curr->tag; 280 int tag = curr->uv.tag;
281 *p = curr->next; 281 *p = curr->uv.next;
282 curr->next = G(L)->TMtable[tag].collected; /* chain udata */ 282 curr->uv.next = G(L)->TMtable[tag].collected; /* chain udata */
283 G(L)->TMtable[tag].collected = curr; 283 G(L)->TMtable[tag].collected = curr;
284 } 284 }
285 } 285 }
@@ -292,15 +292,15 @@ static void collectstrings (lua_State *L, int all) {
292 TString **p = &G(L)->strt.hash[i]; 292 TString **p = &G(L)->strt.hash[i];
293 TString *curr; 293 TString *curr;
294 while ((curr = *p) != NULL) { 294 while ((curr = *p) != NULL) {
295 if (curr->marked && !all) { /* preserve? */ 295 if (curr->tsv.marked && !all) { /* preserve? */
296 if (curr->marked < FIXMARK) /* does not change FIXMARKs */ 296 if (curr->tsv.marked < FIXMARK) /* does not change FIXMARKs */
297 curr->marked = 0; 297 curr->tsv.marked = 0;
298 p = &curr->nexthash; 298 p = &curr->tsv.nexthash;
299 } 299 }
300 else { /* collect */ 300 else { /* collect */
301 *p = curr->nexthash; 301 *p = curr->tsv.nexthash;
302 G(L)->strt.nuse--; 302 G(L)->strt.nuse--;
303 luaM_free(L, curr, sizestring(curr->len)); 303 luaM_free(L, curr, sizestring(curr->tsv.len));
304 } 304 }
305 } 305 }
306 } 306 }
@@ -344,10 +344,10 @@ void luaC_callgcTMudata (lua_State *L) {
344 Udata *udata; 344 Udata *udata;
345 while ((udata = G(L)->TMtable[tag].collected) != NULL) { 345 while ((udata = G(L)->TMtable[tag].collected) != NULL) {
346 TObject obj; 346 TObject obj;
347 G(L)->TMtable[tag].collected = udata->next; /* remove it from list */ 347 G(L)->TMtable[tag].collected = udata->uv.next; /* remove it from list */
348 setuvalue(&obj, udata); 348 setuvalue(&obj, udata);
349 callgcTM(L, &obj); 349 callgcTM(L, &obj);
350 luaM_free(L, udata, sizeudata(udata->len)); 350 luaM_free(L, udata, sizeudata(udata->uv.len));
351 } 351 }
352 } 352 }
353} 353}