diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2017-12-11 10:27:48 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2017-12-11 10:27:48 -0200 |
commit | c5ebed73997c118306e548ac5ccb98302dbf90e4 (patch) | |
tree | de09effd114653d4e8e0a337c357c2b033973890 /lmem.c | |
parent | e663a24ab03a54fa221c20a793812e5c5ffdf94f (diff) | |
download | lua-c5ebed73997c118306e548ac5ccb98302dbf90e4.tar.gz lua-c5ebed73997c118306e548ac5ccb98302dbf90e4.tar.bz2 lua-c5ebed73997c118306e548ac5ccb98302dbf90e4.zip |
'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)
Diffstat (limited to 'lmem.c')
-rw-r--r-- | lmem.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lmem.c,v 1.93 2017/12/07 18:59:52 roberto Exp roberto $ | 2 | ** $Id: lmem.c,v 1.94 2017/12/08 17:28:25 roberto Exp roberto $ |
3 | ** Interface to Memory Manager | 3 | ** Interface to Memory Manager |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -89,7 +89,7 @@ void *luaM_shrinkvector_ (lua_State *L, void *block, int *size, | |||
89 | lua_assert(newsize <= oldsize); | 89 | lua_assert(newsize <= oldsize); |
90 | newblock = (*g->frealloc)(g->ud, block, oldsize, newsize); | 90 | newblock = (*g->frealloc)(g->ud, block, oldsize, newsize); |
91 | if (newblock == NULL && final_n > 0) /* allocation failed? */ | 91 | if (newblock == NULL && final_n > 0) /* allocation failed? */ |
92 | return block; /* keep old block */ | 92 | luaM_error(L); |
93 | else { | 93 | else { |
94 | g->GCdebt += newsize - oldsize; | 94 | g->GCdebt += newsize - oldsize; |
95 | *size = final_n; | 95 | *size = final_n; |