diff options
-rw-r--r-- | lgc.c | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lgc.c,v 2.159 2013/09/11 12:26:14 roberto Exp roberto $ | 2 | ** $Id: lgc.c,v 2.160 2013/09/11 12:47:48 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 | */ |
@@ -740,7 +740,7 @@ static GCObject **sweeplist (lua_State *L, GCObject **p, lu_mem count) { | |||
740 | ** sweep a list until a live object (or end of list) | 740 | ** sweep a list until a live object (or end of list) |
741 | */ | 741 | */ |
742 | static GCObject **sweeptolive (lua_State *L, GCObject **p, int *n) { | 742 | static GCObject **sweeptolive (lua_State *L, GCObject **p, int *n) { |
743 | GCObject ** old = p; | 743 | GCObject **old = p; |
744 | int i = 0; | 744 | int i = 0; |
745 | do { | 745 | do { |
746 | i++; | 746 | i++; |
@@ -1046,6 +1046,8 @@ static int entersweep (lua_State *L) { | |||
1046 | g->gcstate = GCSsweeplocal; | 1046 | g->gcstate = GCSsweeplocal; |
1047 | lua_assert(g->sweepgc == NULL); | 1047 | lua_assert(g->sweepgc == NULL); |
1048 | g->sweepgc = sweeptolive(L, &g->localgc, &n); | 1048 | g->sweepgc = sweeptolive(L, &g->localgc, &n); |
1049 | if (g->sweepgc == NULL) /* no live objects in local list? */ | ||
1050 | g->sweepgc = &g->localgc; /* 'sweepgc' cannot be NULL here */ | ||
1049 | return n; | 1051 | return n; |
1050 | } | 1052 | } |
1051 | 1053 | ||
@@ -1109,11 +1111,10 @@ static l_mem atomic (lua_State *L) { | |||
1109 | 1111 | ||
1110 | static lu_mem sweepstep (lua_State *L, global_State *g, | 1112 | static lu_mem sweepstep (lua_State *L, global_State *g, |
1111 | int nextstate, GCObject **nextlist) { | 1113 | int nextstate, GCObject **nextlist) { |
1112 | if (g->sweepgc) { /* is there still something to sweep? */ | 1114 | g->sweepgc = sweeplist(L, g->sweepgc, GCSWEEPMAX); |
1113 | g->sweepgc = sweeplist(L, g->sweepgc, GCSWEEPMAX); | 1115 | if (g->sweepgc) /* is there still something to sweep? */ |
1114 | return (GCSWEEPMAX * GCSWEEPCOST); | 1116 | return (GCSWEEPMAX * GCSWEEPCOST); |
1115 | } | 1117 | else { /* enter next state */ |
1116 | else { /* next phase */ | ||
1117 | g->gcstate = nextstate; | 1118 | g->gcstate = nextstate; |
1118 | g->sweepgc = nextlist; | 1119 | g->sweepgc = nextlist; |
1119 | return 0; | 1120 | return 0; |