lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Greetings, dear Wu:
No, the first idea came to my mind was to call `luaH_resize(L, h, 0, 0)`. it failed and crashed!
I have read the code of `luaH_resize(L, h, 0, 0)`, it only re-size the space but NOT deal with **ref-relationship** among gc objects. 
objects will be freed in C, but available in lua, thus it crashed.

2017-01-11 11:39 GMT+08:00 云风 Cloud Wu <>:

Xianfu Pan <>于2017年1月11日周三 上午10:03写道:

and `luaC_resettable` is implemented as follows in "lgc.c"
void luaC_resettable(lua_State *L, Table *h) {
/*need not to barrierback, because new value is NIL*/
Node *n, *limit = gnodelast(h);
unsigned int i;
for (i = 0; i < h->sizearray; i++){
TValue *cell = &h->array[i];
for (n = gnode(h, 0); n < limit; n++) {  /* traverse hash part */
TValue *cell = gval(n);
if (!ttisnil(cell))

Are there any issues/pitfalls of my implementation. Or any advices for me?
Many thanks.

I think you can call luaH_resize(L, h, 0, 0) instead of luaC_resettable you implement.