aboutsummaryrefslogtreecommitdiff
path: root/lmem.c
diff options
context:
space:
mode:
Diffstat (limited to 'lmem.c')
-rw-r--r--lmem.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/lmem.c b/lmem.c
index 6622ea9a..dd19a27c 100644
--- a/lmem.c
+++ b/lmem.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lmem.c,v 1.58 2002/10/08 18:45:07 roberto Exp roberto $ 2** $Id: lmem.c,v 1.59 2002/10/25 21:29:20 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*/
@@ -67,6 +67,7 @@ void *luaM_realloc (lua_State *L, void *block, lu_mem oldsize, lu_mem size) {
67 l_free(block, oldsize); 67 l_free(block, oldsize);
68 block = NULL; 68 block = NULL;
69 } 69 }
70 else return NULL; /* avoid `nblocks' computations when oldsize==size==0 */
70 } 71 }
71 else if (size >= MAX_SIZET) 72 else if (size >= MAX_SIZET)
72 luaG_runerror(L, "memory allocation error: block too big"); 73 luaG_runerror(L, "memory allocation error: block too big");
@@ -78,7 +79,8 @@ void *luaM_realloc (lua_State *L, void *block, lu_mem oldsize, lu_mem size) {
78 else return NULL; /* error before creating state! */ 79 else return NULL; /* error before creating state! */
79 } 80 }
80 } 81 }
81 if (L && G(L)) { 82 if (L) {
83 lua_assert(G(L) != NULL && G(L)->nblocks > 0);
82 G(L)->nblocks -= oldsize; 84 G(L)->nblocks -= oldsize;
83 G(L)->nblocks += size; 85 G(L)->nblocks += size;
84 } 86 }