summaryrefslogtreecommitdiff
path: root/lmem.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-04-22 11:40:23 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-04-22 11:40:23 -0300
commitf388ee4a822b3d8027ed7c28aa21e9406e4a11eb (patch)
tree33053e6e31ac1dee0fe27ff7fdba64325a624fe1 /lmem.c
parent30ad4c75db38639f52fb1c8be1c5a3f5b58e776f (diff)
downloadlua-f388ee4a822b3d8027ed7c28aa21e9406e4a11eb.tar.gz
lua-f388ee4a822b3d8027ed7c28aa21e9406e4a11eb.tar.bz2
lua-f388ee4a822b3d8027ed7c28aa21e9406e4a11eb.zip
new way to handle errors
Diffstat (limited to 'lmem.c')
-rw-r--r--lmem.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/lmem.c b/lmem.c
index 33181016..435cceef 100644
--- a/lmem.c
+++ b/lmem.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lmem.c,v 1.51 2001/10/25 19:13:33 roberto Exp $ 2** $Id: lmem.c,v 1.52 2001/11/28 20:13:13 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*/
@@ -34,7 +34,7 @@ void *luaM_growaux (lua_State *L, void *block, int *size, int size_elems,
34 else if (*size >= limit/2) { /* cannot double it? */ 34 else if (*size >= limit/2) { /* cannot double it? */
35 if (*size < limit - MINSIZEARRAY) /* try something smaller... */ 35 if (*size < limit - MINSIZEARRAY) /* try something smaller... */
36 newsize = limit; /* still have at least MINSIZEARRAY free places */ 36 newsize = limit; /* still have at least MINSIZEARRAY free places */
37 else luaD_error(L, errormsg); 37 else luaD_runerror(L, errormsg);
38 } 38 }
39 newblock = luaM_realloc(L, block, 39 newblock = luaM_realloc(L, block,
40 cast(lu_mem, *size)*cast(lu_mem, size_elems), 40 cast(lu_mem, *size)*cast(lu_mem, size_elems),
@@ -53,12 +53,12 @@ void *luaM_realloc (lua_State *L, void *block, lu_mem oldsize, lu_mem size) {
53 block = NULL; 53 block = NULL;
54 } 54 }
55 else if (size >= MAX_SIZET) 55 else if (size >= MAX_SIZET)
56 luaD_error(L, "memory allocation error: block too big"); 56 luaD_runerror(L, "memory allocation error: block too big");
57 else { 57 else {
58 block = l_realloc(block, oldsize, size); 58 block = l_realloc(block, oldsize, size);
59 if (block == NULL) { 59 if (block == NULL) {
60 if (L) 60 if (L)
61 luaD_breakrun(L, LUA_ERRMEM); /* break run without error message */ 61 luaD_error(L, NULL, LUA_ERRMEM); /* break run without error message */
62 else return NULL; /* error before creating state! */ 62 else return NULL; /* error before creating state! */
63 } 63 }
64 } 64 }