|
|
@@ -44,9 +44,6 @@
|
|
|
#define feof luat_fs_feof
|
|
|
#define getc luat_fs_getc
|
|
|
|
|
|
-#define GC_WHAT_RESIZE_BOX 1
|
|
|
-extern int gc_running;
|
|
|
-
|
|
|
/*
|
|
|
** {======================================================
|
|
|
** Traceback
|
|
|
@@ -483,17 +480,6 @@ static void *resizebox (lua_State *L, int idx, size_t newsize) {
|
|
|
lua_Alloc allocf = lua_getallocf(L, &ud);
|
|
|
UBox *box = (UBox *)lua_touserdata(L, idx);
|
|
|
void *temp = allocf(ud, box->box, box->bsize, newsize);
|
|
|
- //-----------------
|
|
|
- // if GC is NOT running, call Full GC
|
|
|
- #if GC_WHAT_RESIZE_BOX
|
|
|
- if (temp == NULL && newsize > 0) {
|
|
|
- if (gc_running == 0) {
|
|
|
- luaC_fullgc(L, 0);
|
|
|
- temp = allocf(ud, box->box, box->bsize, newsize);
|
|
|
- }
|
|
|
- }
|
|
|
- #endif
|
|
|
- //-----------------
|
|
|
if (temp == NULL && newsize > 0) { /* allocation error? */
|
|
|
resizebox(L, idx, 0); /* free buffer */
|
|
|
luaL_error(L, "not enough memory for buffer allocation");
|
|
|
@@ -536,6 +522,7 @@ static void *newbox (lua_State *L, size_t newsize) {
|
|
|
LUALIB_API char *luaL_prepbuffsize (luaL_Buffer *B, size_t sz) {
|
|
|
lua_State *L = B->L;
|
|
|
if (B->size - B->n < sz) { /* not enough space? */
|
|
|
+ luaC_fullgc(L, 0); // add by wendal. GC before luaL_prepbuffsize
|
|
|
char *newbuff;
|
|
|
size_t newsize = B->size * 2; /* double buffer size */
|
|
|
if (newsize - B->n < sz) /* not big enough? */
|