aboutsummaryrefslogtreecommitdiff
path: root/lstring.c
diff options
context:
space:
mode:
Diffstat (limited to 'lstring.c')
-rw-r--r--lstring.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/lstring.c b/lstring.c
index 1b3f53e1..1675b87a 100644
--- a/lstring.c
+++ b/lstring.c
@@ -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*/
75void luaS_resize (lua_State *L, int newsize) { 76void 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 */