** Generic allocation routine. */
| 174 | ** Generic allocation routine. |
| 175 | */ |
| 176 | void *luaM_realloc_ (lua_State *L, void *block, size_t osize, size_t nsize) { |
| 177 | void *newblock; |
| 178 | global_State *g = G(L); |
| 179 | lua_assert((osize == 0) == (block == NULL)); |
| 180 | newblock = firsttry(g, block, osize, nsize); |
| 181 | if (l_unlikely(newblock == NULL && nsize > 0)) { |
| 182 | newblock = tryagain(L, block, osize, nsize); |
| 183 | if (newblock == NULL) /* still no memory? */ |
| 184 | return NULL; /* do not update 'GCdebt' */ |
| 185 | } |
| 186 | lua_assert((nsize == 0) == (newblock == NULL)); |
| 187 | g->GCdebt -= cast(l_mem, nsize) - cast(l_mem, osize); |
| 188 | return newblock; |
| 189 | } |
| 190 | |
| 191 | |
| 192 | void *luaM_saferealloc_ (lua_State *L, void *block, size_t osize, |
no test coverage detected