aboutsummaryrefslogtreecommitdiff
path: root/lmem.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2005-02-23 14:30:22 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2005-02-23 14:30:22 -0300
commitd55bb795faaa3a632aeb92fd29fc12b796ae7968 (patch)
treee81b84b41de1264dd078cec37541716ba0ffcf27 /lmem.c
parentd84cc9d2dbf1f44e7126fe3ed9a82eed9757a63a (diff)
downloadlua-d55bb795faaa3a632aeb92fd29fc12b796ae7968.tar.gz
lua-d55bb795faaa3a632aeb92fd29fc12b796ae7968.tar.bz2
lua-d55bb795faaa3a632aeb92fd29fc12b796ae7968.zip
details
Diffstat (limited to 'lmem.c')
-rw-r--r--lmem.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/lmem.c b/lmem.c
index d48bc09e..a36076fb 100644
--- a/lmem.c
+++ b/lmem.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lmem.c,v 1.67 2004/12/01 15:46:18 roberto Exp roberto $ 2** $Id: lmem.c,v 1.68 2005/01/14 14:21:16 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*/
@@ -22,19 +22,19 @@
22 22
23/* 23/*
24** About the realloc function: 24** About the realloc function:
25** void * realloc (void *ud, void *ptr, size_t osize, size_t nsize); 25** void * frealloc (void *ud, void *ptr, size_t osize, size_t nsize);
26** (`osize' is the old size, `nsize' is the new size) 26** (`osize' is the old size, `nsize' is the new size)
27** 27**
28** Lua ensures that (ptr == NULL) iff (osize == 0). 28** Lua ensures that (ptr == NULL) iff (osize == 0).
29** 29**
30** * realloc(ud, NULL, 0, x) creates a new block of size `x' 30** * frealloc(ud, NULL, 0, x) creates a new block of size `x'
31** 31**
32** * realloc(ud, p, x, 0) frees the block `p' 32** * frealloc(ud, p, x, 0) frees the block `p'
33** (in this specific case, realloc must return NULL). 33** (in this specific case, frealloc must return NULL).
34** particularly, realloc(ud, NULL, 0, 0) does nothing 34** particularly, frealloc(ud, NULL, 0, 0) does nothing
35** (which is equivalent to free(NULL) in ANSI C) 35** (which is equivalent to free(NULL) in ANSI C)
36** 36**
37** realloc returns NULL if it cannot create or reallocate the area 37** frealloc returns NULL if it cannot create or reallocate the area
38** (any reallocation to an equal or smaller size cannot fail!) 38** (any reallocation to an equal or smaller size cannot fail!)
39*/ 39*/
40 40
@@ -76,7 +76,7 @@ void *luaM_toobig (lua_State *L) {
76void *luaM_realloc_ (lua_State *L, void *block, size_t osize, size_t nsize) { 76void *luaM_realloc_ (lua_State *L, void *block, size_t osize, size_t nsize) {
77 global_State *g = G(L); 77 global_State *g = G(L);
78 lua_assert((osize == 0) == (block == NULL)); 78 lua_assert((osize == 0) == (block == NULL));
79 block = (*g->realloc)(g->ud, block, osize, nsize); 79 block = (*g->frealloc)(g->ud, block, osize, nsize);
80 if (block == NULL && nsize > 0) 80 if (block == NULL && nsize > 0)
81 luaD_throw(L, LUA_ERRMEM); 81 luaD_throw(L, LUA_ERRMEM);
82 lua_assert((nsize == 0) == (block == NULL)); 82 lua_assert((nsize == 0) == (block == NULL));