allocation function is not exactly API (and cannot raise errors
like other API functions); better not use 'api_check' for cheking it.
This commit is contained in:
5
lmem.c
5
lmem.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lmem.c,v 1.89 2014/11/02 19:33:33 roberto Exp roberto $
|
** $Id: lmem.c,v 1.90 2015/03/03 18:18:29 roberto Exp roberto $
|
||||||
** Interface to Memory Manager
|
** Interface to Memory Manager
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -85,8 +85,7 @@ void *luaM_realloc_ (lua_State *L, void *block, size_t osize, size_t nsize) {
|
|||||||
#endif
|
#endif
|
||||||
newblock = (*g->frealloc)(g->ud, block, osize, nsize);
|
newblock = (*g->frealloc)(g->ud, block, osize, nsize);
|
||||||
if (newblock == NULL && nsize > 0) {
|
if (newblock == NULL && nsize > 0) {
|
||||||
api_check( nsize > realosize,
|
lua_assert(nsize > realosize); /* cannot fail when shrinking a block */
|
||||||
"realloc cannot fail when shrinking a block");
|
|
||||||
if (g->version) { /* is state fully built? */
|
if (g->version) { /* is state fully built? */
|
||||||
luaC_fullgc(L, 1); /* try to free some memory... */
|
luaC_fullgc(L, 1); /* try to free some memory... */
|
||||||
newblock = (*g->frealloc)(g->ud, block, osize, nsize); /* try again */
|
newblock = (*g->frealloc)(g->ud, block, osize, nsize); /* try again */
|
||||||
|
|||||||
Reference in New Issue
Block a user