Fix alloc/free sizes of internal GCRef arrays.

This commit is contained in:
Mike Pall 2009-12-29 04:36:35 +01:00
parent 81c9f5de89
commit 24429ed1f5
5 changed files with 5 additions and 5 deletions

View File

@ -47,7 +47,7 @@ GCproto *lj_func_newproto(lua_State *L)
void LJ_FASTCALL lj_func_freeproto(global_State *g, GCproto *pt) void LJ_FASTCALL lj_func_freeproto(global_State *g, GCproto *pt)
{ {
MSize nkgc = round_nkgc(pt->sizekgc); MSize nkgc = round_nkgc(pt->sizekgc);
MSize sizek = nkgc*(MSize)sizeof(GCobj *) + MSize sizek = nkgc*(MSize)sizeof(GCRef) +
pt->sizekn*(MSize)sizeof(lua_Number); pt->sizekn*(MSize)sizeof(lua_Number);
lj_mem_free(g, pt->k.gc - nkgc, sizek); lj_mem_free(g, pt->k.gc - nkgc, sizek);
lj_mem_freevec(g, pt->bc, pt->sizebc, BCIns); lj_mem_freevec(g, pt->bc, pt->sizebc, BCIns);

View File

@ -327,7 +327,7 @@ static size_t propagatemark(global_State *g)
GCproto *pt = gco2pt(o); GCproto *pt = gco2pt(o);
gc_traverse_proto(g, pt); gc_traverse_proto(g, pt);
return sizeof(GCproto) + sizeof(BCIns) * pt->sizebc + return sizeof(GCproto) + sizeof(BCIns) * pt->sizebc +
sizeof(GCobj *) * pt->sizekgc + sizeof(GCRef) * pt->sizekgc +
sizeof(lua_Number) * pt->sizekn + sizeof(lua_Number) * pt->sizekn +
sizeof(int16_t) * pt->sizeuv + sizeof(int16_t) * pt->sizeuv +
sizeof(int32_t) * pt->sizelineinfo + sizeof(int32_t) * pt->sizelineinfo +

View File

@ -1140,7 +1140,7 @@ static void collectk(FuncState *fs, GCproto *pt)
checklimitgt(fs, fs->nkn, BCMAX_D+1, "constants"); checklimitgt(fs, fs->nkn, BCMAX_D+1, "constants");
checklimitgt(fs, fs->nkgc, BCMAX_D+1, "constants"); checklimitgt(fs, fs->nkgc, BCMAX_D+1, "constants");
nkgc = round_nkgc(fs->nkgc); nkgc = round_nkgc(fs->nkgc);
sizek = (MSize)(nkgc*sizeof(MRef) + fs->nkn*sizeof(lua_Number)); sizek = (MSize)(nkgc*sizeof(GCRef) + fs->nkn*sizeof(lua_Number));
kstart = lj_mem_newt(fs->L, sizek, GCRef); kstart = lj_mem_newt(fs->L, sizek, GCRef);
if (nkgc) setgcrefnull(kstart[0]); /* May be uninitialized otherwise. */ if (nkgc) setgcrefnull(kstart[0]); /* May be uninitialized otherwise. */
pt->k.gc = kstart + nkgc; pt->k.gc = kstart + nkgc;

View File

@ -150,7 +150,7 @@ static void close_state(lua_State *L)
lua_assert(gcref(g->gc.root) == obj2gco(L)); lua_assert(gcref(g->gc.root) == obj2gco(L));
lua_assert(g->strnum == 0); lua_assert(g->strnum == 0);
lj_trace_freestate(g); lj_trace_freestate(g);
lj_mem_freevec(g, g->strhash, g->strmask+1, GCstr *); lj_mem_freevec(g, g->strhash, g->strmask+1, GCRef);
lj_str_freebuf(g, &g->tmpbuf); lj_str_freebuf(g, &g->tmpbuf);
lj_mem_freevec(g, L->stack, L->stacksize, TValue); lj_mem_freevec(g, L->stack, L->stacksize, TValue);
lua_assert(g->gc.total == sizeof(GG_State)); lua_assert(g->gc.total == sizeof(GG_State));

View File

@ -64,7 +64,7 @@ void lj_str_resize(lua_State *L, MSize newmask)
p = next; p = next;
} }
} }
lj_mem_freevec(g, g->strhash, g->strmask+1, GCstr *); lj_mem_freevec(g, g->strhash, g->strmask+1, GCRef);
g->strmask = newmask; g->strmask = newmask;
g->strhash = newhash; g->strhash = newhash;
} }