MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / luaS_resize

Function luaS_resize

lib/lua/src/lstring.c:85–103  ·  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

83** correctly.)
84*/
85void luaS_resize (lua_State *L, int nsize) {
86 stringtable *tb = &G(L)->strt;
87 int osize = tb->size;
88 TString **newvect;
89 if (nsize < osize) /* shrinking table? */
90 tablerehash(tb->hash, osize, nsize); /* depopulate shrinking part */
91 newvect = luaM_reallocvector(L, tb->hash, osize, nsize, TString*);
92 if (l_unlikely(newvect == NULL)) { /* reallocation failed? */
93 if (nsize < osize) /* was it shrinking table? */
94 tablerehash(tb->hash, nsize, osize); /* restore to original size */
95 /* leave table as it was */
96 }
97 else { /* allocation succeeded */
98 tb->hash = newvect;
99 tb->size = nsize;
100 if (nsize > osize)
101 tablerehash(newvect, osize, nsize); /* rehash for new size */
102 }
103}
104
105
106/*

Callers 2

growstrtabFunction · 0.85
checkSizesFunction · 0.85

Calls 2

tablerehashFunction · 0.85
GFunction · 0.50

Tested by

no test coverage detected