MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / tryagain

Function tryagain

3rd/lua-5.4.3/src/lmem.c:148–156  ·  view source on GitHub ↗

** In case of allocation fail, this function will do an emergency ** collection to free some memory and then try the allocation again. ** The GC should not be called while state is not fully built, as the ** collector is not yet fully initialized. Also, it should not be called ** when 'gcstopem' is true, because then the interpreter is in the ** middle of a collection step. */

Source from the content-addressed store, hash-verified

146** middle of a collection step.
147*/
148static void *tryagain (lua_State *L, void *block,
149 size_t osize, size_t nsize) {
150 global_State *g = G(L);
151 if (completestate(g) && !g->gcstopem) {
152 luaC_fullgc(L, 1); /* try to free some memory... */
153 return (*g->frealloc)(g->ud, block, osize, nsize); /* try again */
154 }
155 else return NULL; /* cannot free any memory without a full state */
156}
157
158
159/*

Callers 2

luaM_realloc_Function · 0.85
luaM_malloc_Function · 0.85

Calls 1

luaC_fullgcFunction · 0.85

Tested by

no test coverage detected