mirror of
https://github.com/lua/lua
synced 2024-11-25 22:29:39 +03:00
'luaM_shrinkvector' raises an error if it cannot shrink the block
(several parts of Lua use array size in protos as proxies for number of valid elements)
This commit is contained in:
parent
e663a24ab0
commit
c5ebed7399
4
lmem.c
4
lmem.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lmem.c,v 1.93 2017/12/07 18:59:52 roberto Exp roberto $
|
||||
** $Id: lmem.c,v 1.94 2017/12/08 17:28:25 roberto Exp roberto $
|
||||
** Interface to Memory Manager
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -89,7 +89,7 @@ void *luaM_shrinkvector_ (lua_State *L, void *block, int *size,
|
||||
lua_assert(newsize <= oldsize);
|
||||
newblock = (*g->frealloc)(g->ud, block, oldsize, newsize);
|
||||
if (newblock == NULL && final_n > 0) /* allocation failed? */
|
||||
return block; /* keep old block */
|
||||
luaM_error(L);
|
||||
else {
|
||||
g->GCdebt += newsize - oldsize;
|
||||
*size = final_n;
|
||||
|
Loading…
Reference in New Issue
Block a user