MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / luaS_resize

Function luaS_resize

third-party/lua-5.5.0/src/lstring.c:95–113  ·  view source on GitHub ↗

** Resize the string table. If allocation fails, keep the current size. ** (This can degrade performance, but any non-zero size should work ** correctly.) */

Source from the content-addressed store, hash-verified

93** correctly.)
94*/
95void luaS_resize (lua_State *L, int nsize) {
96 stringtable *tb = &G(L)->strt;
97 int osize = tb->size;
98 TString **newvect;
99 if (nsize < osize) /* shrinking table? */
100 tablerehash(tb->hash, osize, nsize); /* depopulate shrinking part */
101 newvect = luaM_reallocvector(L, tb->hash, osize, nsize, TString*);
102 if (l_unlikely(newvect == NULL)) { /* reallocation failed? */
103 if (nsize < osize) /* was it shrinking table? */
104 tablerehash(tb->hash, nsize, osize); /* restore to original size */
105 /* leave table as it was */
106 }
107 else { /* allocation succeeded */
108 tb->hash = newvect;
109 tb->size = nsize;
110 if (nsize > osize)
111 tablerehash(newvect, osize, nsize); /* rehash for new size */
112 }
113}
114
115
116/*

Callers 2

growstrtabFunction · 0.70
checkSizesFunction · 0.70

Calls 1

tablerehashFunction · 0.70

Tested by

no test coverage detected