MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / luaM_shrinkvector_

Function luaM_shrinkvector_

3rd/lua-5.4.3/src/lmem.c:110–119  ·  view source on GitHub ↗

** In prototypes, the size of the array is also its number of ** elements (to save memory). So, if it cannot shrink an array ** to its number of elements, the only option is to raise an ** error. */

Source from the content-addressed store, hash-verified

108** error.
109*/
110void *luaM_shrinkvector_ (lua_State *L, void *block, int *size,
111 int final_n, int size_elem) {
112 void *newblock;
113 size_t oldsize = cast_sizet((*size) * size_elem);
114 size_t newsize = cast_sizet(final_n * size_elem);
115 lua_assert(newsize <= oldsize);
116 newblock = luaM_saferealloc_(L, block, oldsize, newsize);
117 *size = final_n;
118 return newblock;
119}
120
121/* }================================================================== */
122

Callers

nothing calls this directly

Calls 1

luaM_saferealloc_Function · 0.85

Tested by

no test coverage detected