mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-02-07 23:24:09 +00:00
FFI: Add debug define to check for unanchored CTypes.
This commit is contained in:
parent
2ad9834df6
commit
405020c405
@ -132,7 +132,11 @@ CTKWDEF(CTKWNAMEDEF)
|
|||||||
;
|
;
|
||||||
|
|
||||||
#define CTTYPEINFO_NUM (sizeof(lj_ctype_typeinfo)/sizeof(CTInfo)-1)
|
#define CTTYPEINFO_NUM (sizeof(lj_ctype_typeinfo)/sizeof(CTInfo)-1)
|
||||||
|
#ifdef LUAJIT_CTYPE_CHECK_ANCHOR
|
||||||
|
#define CTTYPETAB_MIN CTTYPEINFO_NUM
|
||||||
|
#else
|
||||||
#define CTTYPETAB_MIN 128
|
#define CTTYPETAB_MIN 128
|
||||||
|
#endif
|
||||||
|
|
||||||
/* -- C type interning ---------------------------------------------------- */
|
/* -- C type interning ---------------------------------------------------- */
|
||||||
|
|
||||||
@ -148,7 +152,16 @@ CTypeID lj_ctype_new(CTState *cts, CType **ctp)
|
|||||||
lua_assert(cts->L);
|
lua_assert(cts->L);
|
||||||
if (LJ_UNLIKELY(id >= cts->sizetab)) {
|
if (LJ_UNLIKELY(id >= cts->sizetab)) {
|
||||||
if (id >= CTID_MAX) lj_err_msg(cts->L, LJ_ERR_TABOV);
|
if (id >= CTID_MAX) lj_err_msg(cts->L, LJ_ERR_TABOV);
|
||||||
|
#ifdef LUAJIT_CTYPE_CHECK_ANCHOR
|
||||||
|
ct = lj_mem_newvec(cts->L, id+1, CType);
|
||||||
|
memcpy(ct, cts->tab, id*sizeof(CType));
|
||||||
|
memset(cts->tab, 0, id*sizeof(CType));
|
||||||
|
lj_mem_freevec(cts->g, cts->tab, cts->sizetab, CType);
|
||||||
|
cts->tab = ct;
|
||||||
|
cts->sizetab = id+1;
|
||||||
|
#else
|
||||||
lj_mem_growvec(cts->L, cts->tab, cts->sizetab, CTID_MAX, CType);
|
lj_mem_growvec(cts->L, cts->tab, cts->sizetab, CTID_MAX, CType);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
cts->top = id+1;
|
cts->top = id+1;
|
||||||
*ctp = ct = &cts->tab[id];
|
*ctp = ct = &cts->tab[id];
|
||||||
|
Loading…
Reference in New Issue
Block a user