Add gc callback

This commit is contained in:
LoganDark 2021-11-08 11:58:02 -08:00
parent f1649a43cd
commit 7aedc43cc9
No known key found for this signature in database
GPG key ID: B8C37CEDE1AC60EA
2 changed files with 4 additions and 0 deletions

View file

@ -358,6 +358,8 @@ struct lua_Callbacks
void (*debugstep)(lua_State* L, lua_Debug* ar); /* gets called after each instruction in single step mode */
void (*debuginterrupt)(lua_State* L, lua_Debug* ar); /* gets called when thread execution is interrupted by break in another thread */
void (*debugprotectederror)(lua_State* L); /* gets called when protected call results in an error */
void (*gc)(lua_State* L); /* gets called when a garbage collection cycle starts */
};
LUA_API lua_Callbacks* lua_callbacks(lua_State* L);

View file

@ -617,6 +617,8 @@ static void markroot(lua_State* L)
markvalue(g, registry(L));
markmt(g);
g->gcstate = GCSpropagate;
if (g->cb.gc)
g->cb.gc(L);
}
static size_t remarkupvals(global_State* g)