aboutsummaryrefslogtreecommitdiff
path: root/lgc.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-07-18 09:17:54 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-07-18 09:17:54 -0300
commit56137d58ff7abe8cb22ee3469366e08888c84f28 (patch)
tree6769e3c2403a69cf3f0d6dbf6fb4acb7442367e0 /lgc.c
parent9aec500a2691d2b13c307d143868c8a4fab33220 (diff)
downloadlua-56137d58ff7abe8cb22ee3469366e08888c84f28.tar.gz
lua-56137d58ff7abe8cb22ee3469366e08888c84f28.tar.bz2
lua-56137d58ff7abe8cb22ee3469366e08888c84f28.zip
added check for conversion 'obj2gco' (and corrections for small
problems detected by this check)
Diffstat (limited to 'lgc.c')
-rw-r--r--lgc.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/lgc.c b/lgc.c
index 24278dab..ac1c6a46 100644
--- a/lgc.c
+++ b/lgc.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lgc.c,v 2.184 2014/06/30 19:48:08 roberto Exp roberto $ 2** $Id: lgc.c,v 2.185 2014/07/17 17:27:49 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*/
@@ -83,6 +83,9 @@
83#define markobject(g,t) \ 83#define markobject(g,t) \
84 { if ((t) && iswhite(obj2gco(t))) reallymarkobject(g, obj2gco(t)); } 84 { if ((t) && iswhite(obj2gco(t))) reallymarkobject(g, obj2gco(t)); }
85 85
86#define markstring(g,t) \
87 { if ((t) && iswhite(ts2gco(t))) reallymarkobject(g, ts2gco(t)); }
88
86static void reallymarkobject (global_State *g, GCObject *o); 89static void reallymarkobject (global_State *g, GCObject *o);
87 90
88 91
@@ -126,7 +129,7 @@ static void removeentry (Node *n) {
126static int iscleared (global_State *g, const TValue *o) { 129static int iscleared (global_State *g, const TValue *o) {
127 if (!iscollectable(o)) return 0; 130 if (!iscollectable(o)) return 0;
128 else if (ttisstring(o)) { 131 else if (ttisstring(o)) {
129 markobject(g, rawtsvalue(o)); /* strings are `values', so are never weak */ 132 markobject(g, tsvalue(o)); /* strings are `values', so are never weak */
130 return 0; 133 return 0;
131 } 134 }
132 else return iswhite(gcvalue(o)); 135 else return iswhite(gcvalue(o));
@@ -448,15 +451,15 @@ static int traverseproto (global_State *g, Proto *f) {
448 int i; 451 int i;
449 if (f->cache && iswhite(obj2gco(f->cache))) 452 if (f->cache && iswhite(obj2gco(f->cache)))
450 f->cache = NULL; /* allow cache to be collected */ 453 f->cache = NULL; /* allow cache to be collected */
451 markobject(g, f->source); 454 markstring(g, f->source);
452 for (i = 0; i < f->sizek; i++) /* mark literals */ 455 for (i = 0; i < f->sizek; i++) /* mark literals */
453 markvalue(g, &f->k[i]); 456 markvalue(g, &f->k[i]);
454 for (i = 0; i < f->sizeupvalues; i++) /* mark upvalue names */ 457 for (i = 0; i < f->sizeupvalues; i++) /* mark upvalue names */
455 markobject(g, f->upvalues[i].name); 458 markstring(g, f->upvalues[i].name);
456 for (i = 0; i < f->sizep; i++) /* mark nested protos */ 459 for (i = 0; i < f->sizep; i++) /* mark nested protos */
457 markobject(g, f->p[i]); 460 markobject(g, f->p[i]);
458 for (i = 0; i < f->sizelocvars; i++) /* mark local-variable names */ 461 for (i = 0; i < f->sizelocvars; i++) /* mark local-variable names */
459 markobject(g, f->locvars[i].varname); 462 markstring(g, f->locvars[i].varname);
460 return sizeof(Proto) + sizeof(Instruction) * f->sizecode + 463 return sizeof(Proto) + sizeof(Instruction) * f->sizecode +
461 sizeof(Proto *) * f->sizep + 464 sizeof(Proto *) * f->sizep +
462 sizeof(TValue) * f->sizek + 465 sizeof(TValue) * f->sizek +