diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2017-12-18 11:00:57 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2017-12-18 11:00:57 -0200 |
commit | 2f6f6abeba452bbbbaeb0e4d70e748e46d314894 (patch) | |
tree | 95231c53d13f524d76d4c077c9491547ed9eb637 /lstring.c | |
parent | 3064edead20a04ac29dfb315fe7ff87d8c6b164d (diff) | |
download | lua-2f6f6abeba452bbbbaeb0e4d70e748e46d314894.tar.gz lua-2f6f6abeba452bbbbaeb0e4d70e748e46d314894.tar.bz2 lua-2f6f6abeba452bbbbaeb0e4d70e748e46d314894.zip |
'rehash' -> 'tablerehash'
(to avoid name colisions when compiling Lua as a single file)
Diffstat (limited to 'lstring.c')
-rw-r--r-- | lstring.c | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lstring.c,v 2.60 2017/12/08 17:28:25 roberto Exp roberto $ | 2 | ** $Id: lstring.c,v 2.61 2017/12/12 11:52:35 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 | */ |
@@ -69,7 +69,7 @@ unsigned int luaS_hashlongstr (TString *ts) { | |||
69 | } | 69 | } |
70 | 70 | ||
71 | 71 | ||
72 | static void rehash (TString **vect, int osize, int nsize) { | 72 | static void tablerehash (TString **vect, int osize, int nsize) { |
73 | int i; | 73 | int i; |
74 | for (i = osize; i < nsize; i++) /* clear new elements */ | 74 | for (i = osize; i < nsize; i++) /* clear new elements */ |
75 | vect[i] = NULL; | 75 | vect[i] = NULL; |
@@ -97,18 +97,18 @@ void luaS_resize (lua_State *L, int nsize) { | |||
97 | int osize = tb->size; | 97 | int osize = tb->size; |
98 | TString **newvect; | 98 | TString **newvect; |
99 | if (nsize < osize) /* shrinking table? */ | 99 | if (nsize < osize) /* shrinking table? */ |
100 | rehash(tb->hash, osize, nsize); /* remove elements from shrinking part */ | 100 | tablerehash(tb->hash, osize, nsize); /* depopulate shrinking part */ |
101 | newvect = luaM_reallocvector(L, tb->hash, osize, nsize, TString*); | 101 | newvect = luaM_reallocvector(L, tb->hash, osize, nsize, TString*); |
102 | if (newvect == NULL) { /* reallocation failed? */ | 102 | if (newvect == NULL) { /* reallocation failed? */ |
103 | if (nsize < osize) /* was it shrinking table? */ | 103 | if (nsize < osize) /* was it shrinking table? */ |
104 | rehash(tb->hash, nsize, osize); /* restore to original size */ | 104 | tablerehash(tb->hash, nsize, osize); /* restore to original size */ |
105 | /* leave table as it was */ | 105 | /* leave table as it was */ |
106 | } | 106 | } |
107 | else { /* allocation succeeded */ | 107 | else { /* allocation succeeded */ |
108 | tb->hash = newvect; | 108 | tb->hash = newvect; |
109 | tb->size = nsize; | 109 | tb->size = nsize; |
110 | if (nsize > osize) | 110 | if (nsize > osize) |
111 | rehash(newvect, osize, nsize); /* rehash for new size */ | 111 | tablerehash(newvect, osize, nsize); /* rehash for new size */ |
112 | } | 112 | } |
113 | } | 113 | } |
114 | 114 | ||
@@ -136,7 +136,7 @@ void luaS_init (lua_State *L) { | |||
136 | TString *memerrmsg; | 136 | TString *memerrmsg; |
137 | stringtable *tb = &G(L)->strt; | 137 | stringtable *tb = &G(L)->strt; |
138 | tb->hash = luaM_newvector(L, MINSTRTABSIZE, TString*); | 138 | tb->hash = luaM_newvector(L, MINSTRTABSIZE, TString*); |
139 | rehash(tb->hash, 0, MINSTRTABSIZE); /* clear array */ | 139 | tablerehash(tb->hash, 0, MINSTRTABSIZE); /* clear array */ |
140 | tb->size = MINSTRTABSIZE; | 140 | tb->size = MINSTRTABSIZE; |
141 | /* pre-create memory-error message */ | 141 | /* pre-create memory-error message */ |
142 | memerrmsg = luaS_newliteral(L, MEMERRMSG); | 142 | memerrmsg = luaS_newliteral(L, MEMERRMSG); |