diff options
Diffstat (limited to 'lstring.c')
| -rw-r--r-- | lstring.c | 16 |
1 files changed, 13 insertions, 3 deletions
| @@ -25,7 +25,17 @@ | |||
| 25 | /* | 25 | /* |
| 26 | ** Maximum size for string table. | 26 | ** Maximum size for string table. |
| 27 | */ | 27 | */ |
| 28 | #define MAXSTRTB cast_int(luaM_limitN(MAX_INT, TString*)) | 28 | #define MAXSTRTB cast_int(luaM_limitN(INT_MAX, TString*)) |
| 29 | |||
| 30 | /* | ||
| 31 | ** Initial size for the string table (must be power of 2). | ||
| 32 | ** The Lua core alone registers ~50 strings (reserved words + | ||
| 33 | ** metaevent keys + a few others). Libraries would typically add | ||
| 34 | ** a few dozens more. | ||
| 35 | */ | ||
| 36 | #if !defined(MINSTRTABSIZE) | ||
| 37 | #define MINSTRTABSIZE 128 | ||
| 38 | #endif | ||
| 29 | 39 | ||
| 30 | 40 | ||
| 31 | /* | 41 | /* |
| @@ -188,9 +198,9 @@ void luaS_remove (lua_State *L, TString *ts) { | |||
| 188 | 198 | ||
| 189 | 199 | ||
| 190 | static void growstrtab (lua_State *L, stringtable *tb) { | 200 | static void growstrtab (lua_State *L, stringtable *tb) { |
| 191 | if (l_unlikely(tb->nuse == MAX_INT)) { /* too many strings? */ | 201 | if (l_unlikely(tb->nuse == INT_MAX)) { /* too many strings? */ |
| 192 | luaC_fullgc(L, 1); /* try to free some... */ | 202 | luaC_fullgc(L, 1); /* try to free some... */ |
| 193 | if (tb->nuse == MAX_INT) /* still too many? */ | 203 | if (tb->nuse == INT_MAX) /* still too many? */ |
| 194 | luaM_error(L); /* cannot even create a message... */ | 204 | luaM_error(L); /* cannot even create a message... */ |
| 195 | } | 205 | } |
| 196 | if (tb->size <= MAXSTRTB / 2) /* can grow string table? */ | 206 | if (tb->size <= MAXSTRTB / 2) /* can grow string table? */ |
