aboutsummaryrefslogtreecommitdiff
path: root/lmem.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2021-02-05 17:51:25 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2021-02-05 17:51:25 -0300
commitc63e5d212bc5dec1b1c749e3f07b42cd83081826 (patch)
tree35c2dc1d828e0ec9c89d60ac2702b847e002a68f /lmem.c
parentdee6433a89b088a1f8da9531a92a2a2693e5dac7 (diff)
downloadlua-c63e5d212bc5dec1b1c749e3f07b42cd83081826.tar.gz
lua-c63e5d212bc5dec1b1c749e3f07b42cd83081826.tar.bz2
lua-c63e5d212bc5dec1b1c749e3f07b42cd83081826.zip
New macro 'completestate'
Diffstat (limited to 'lmem.c')
-rw-r--r--lmem.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lmem.c b/lmem.c
index 43739bff..4822a0ea 100644
--- a/lmem.c
+++ b/lmem.c
@@ -29,7 +29,7 @@
29** a full GC cycle at every allocation.) 29** a full GC cycle at every allocation.)
30*/ 30*/
31static void *firsttry (global_State *g, void *block, size_t os, size_t ns) { 31static void *firsttry (global_State *g, void *block, size_t os, size_t ns) {
32 if (ttisnil(&g->nilvalue) && ns > os) 32 if (completestate(g) && ns > os)
33 return NULL; /* fail */ 33 return NULL; /* fail */
34 else /* normal allocation */ 34 else /* normal allocation */
35 return (*g->frealloc)(g->ud, block, os, ns); 35 return (*g->frealloc)(g->ud, block, os, ns);
@@ -146,7 +146,7 @@ void luaM_free_ (lua_State *L, void *block, size_t osize) {
146static void *tryagain (lua_State *L, void *block, 146static void *tryagain (lua_State *L, void *block,
147 size_t osize, size_t nsize) { 147 size_t osize, size_t nsize) {
148 global_State *g = G(L); 148 global_State *g = G(L);
149 if (ttisnil(&g->nilvalue)) { /* is state fully build? */ 149 if (completestate(g)) { /* is state fully build? */
150 luaC_fullgc(L, 1); /* try to free some memory... */ 150 luaC_fullgc(L, 1); /* try to free some memory... */
151 return (*g->frealloc)(g->ud, block, osize, nsize); /* try again */ 151 return (*g->frealloc)(g->ud, block, osize, nsize); /* try again */
152 } 152 }