mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-02-07 15:14:08 +00:00
Fix alloc/free sizes of internal GCRef arrays.
This commit is contained in:
parent
81c9f5de89
commit
24429ed1f5
@ -47,7 +47,7 @@ GCproto *lj_func_newproto(lua_State *L)
|
||||
void LJ_FASTCALL lj_func_freeproto(global_State *g, GCproto *pt)
|
||||
{
|
||||
MSize nkgc = round_nkgc(pt->sizekgc);
|
||||
MSize sizek = nkgc*(MSize)sizeof(GCobj *) +
|
||||
MSize sizek = nkgc*(MSize)sizeof(GCRef) +
|
||||
pt->sizekn*(MSize)sizeof(lua_Number);
|
||||
lj_mem_free(g, pt->k.gc - nkgc, sizek);
|
||||
lj_mem_freevec(g, pt->bc, pt->sizebc, BCIns);
|
||||
|
@ -327,7 +327,7 @@ static size_t propagatemark(global_State *g)
|
||||
GCproto *pt = gco2pt(o);
|
||||
gc_traverse_proto(g, pt);
|
||||
return sizeof(GCproto) + sizeof(BCIns) * pt->sizebc +
|
||||
sizeof(GCobj *) * pt->sizekgc +
|
||||
sizeof(GCRef) * pt->sizekgc +
|
||||
sizeof(lua_Number) * pt->sizekn +
|
||||
sizeof(int16_t) * pt->sizeuv +
|
||||
sizeof(int32_t) * pt->sizelineinfo +
|
||||
|
@ -1140,7 +1140,7 @@ static void collectk(FuncState *fs, GCproto *pt)
|
||||
checklimitgt(fs, fs->nkn, BCMAX_D+1, "constants");
|
||||
checklimitgt(fs, fs->nkgc, BCMAX_D+1, "constants");
|
||||
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);
|
||||
if (nkgc) setgcrefnull(kstart[0]); /* May be uninitialized otherwise. */
|
||||
pt->k.gc = kstart + nkgc;
|
||||
|
@ -150,7 +150,7 @@ static void close_state(lua_State *L)
|
||||
lua_assert(gcref(g->gc.root) == obj2gco(L));
|
||||
lua_assert(g->strnum == 0);
|
||||
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_mem_freevec(g, L->stack, L->stacksize, TValue);
|
||||
lua_assert(g->gc.total == sizeof(GG_State));
|
||||
|
@ -64,7 +64,7 @@ void lj_str_resize(lua_State *L, MSize newmask)
|
||||
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->strhash = newhash;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user