diff options
Diffstat (limited to 'lstring.c')
-rw-r--r-- | lstring.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lstring.c,v 2.58 2017/12/01 16:40:29 roberto Exp roberto $ | 2 | ** $Id: lstring.c,v 2.59 2017/12/07 18:59:52 roberto Exp roberto $ |
3 | ** String table (keeps all strings handled by Lua) | 3 | ** String table (keeps all strings handled by Lua) |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -70,12 +70,15 @@ unsigned int luaS_hashlongstr (TString *ts) { | |||
70 | 70 | ||
71 | 71 | ||
72 | /* | 72 | /* |
73 | ** Resizes the string table. | 73 | ** Resize the string table. If allocation fails, keep the current size. |
74 | ** (This can degrade performance, but any size should work correctly.) | ||
74 | */ | 75 | */ |
75 | void luaS_resize (lua_State *L, int newsize) { | 76 | void luaS_resize (lua_State *L, int newsize) { |
76 | int i; | 77 | int i; |
77 | TString **newhash = luaM_newvector(L, newsize, TString *); | 78 | TString **newhash = luaM_newvector(L, newsize, TString *); |
78 | stringtable *tb = &G(L)->strt; | 79 | stringtable *tb = &G(L)->strt; |
80 | if (newhash == NULL) /* allocation failed? */ | ||
81 | return; /* leave hash as it is */ | ||
79 | for (i = 0; i < newsize; i++) /* initialize new hash array */ | 82 | for (i = 0; i < newsize; i++) /* initialize new hash array */ |
80 | newhash[i] = NULL; | 83 | newhash[i] = NULL; |
81 | for (i = 0; i < tb->size; i++) { /* rehash all elements into new array */ | 84 | for (i = 0; i < tb->size; i++) { /* rehash all elements into new array */ |