MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / luaM_realloc_

Function luaM_realloc_

extlibs/lua/src/lmem.c:162–176  ·  view source on GitHub ↗

** Generic allocation routine. ** If allocation fails while shrinking a block, do not try again; the ** GC shrinks some blocks and it is not reentrant. */

Source from the content-addressed store, hash-verified

160** GC shrinks some blocks and it is not reentrant.
161*/
162void *luaM_realloc_ (lua_State *L, void *block, size_t osize, size_t nsize) {
163 void *newblock;
164 global_State *g = G(L);
165 lua_assert((osize == 0) == (block == NULL));
166 newblock = firsttry(g, block, osize, nsize);
167 if (unlikely(newblock == NULL && nsize > 0)) {
168 if (nsize > osize) /* not shrinking a block? */
169 newblock = tryagain(L, block, osize, nsize);
170 if (newblock == NULL) /* still no memory? */
171 return NULL; /* do not update 'GCdebt' */
172 }
173 lua_assert((nsize == 0) == (newblock == NULL));
174 g->GCdebt = (g->GCdebt + nsize) - osize;
175 return newblock;
176}
177
178
179void *luaM_saferealloc_ (lua_State *L, void *block, size_t osize,

Callers 1

luaM_saferealloc_Function · 0.85

Calls 2

firsttryFunction · 0.85
tryagainFunction · 0.85

Tested by

no test coverage detected