diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2021-02-05 17:51:25 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2021-02-05 17:51:25 -0300 |
commit | c63e5d212bc5dec1b1c749e3f07b42cd83081826 (patch) | |
tree | 35c2dc1d828e0ec9c89d60ac2702b847e002a68f /lmem.c | |
parent | dee6433a89b088a1f8da9531a92a2a2693e5dac7 (diff) | |
download | lua-c63e5d212bc5dec1b1c749e3f07b42cd83081826.tar.gz lua-c63e5d212bc5dec1b1c749e3f07b42cd83081826.tar.bz2 lua-c63e5d212bc5dec1b1c749e3f07b42cd83081826.zip |
New macro 'completestate'
Diffstat (limited to 'lmem.c')
-rw-r--r-- | lmem.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -29,7 +29,7 @@ | |||
29 | ** a full GC cycle at every allocation.) | 29 | ** a full GC cycle at every allocation.) |
30 | */ | 30 | */ |
31 | static void *firsttry (global_State *g, void *block, size_t os, size_t ns) { | 31 | static 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) { | |||
146 | static void *tryagain (lua_State *L, void *block, | 146 | static 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 | } |