** 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. */
| 126 | ** error. |
| 127 | */ |
| 128 | void *luaM_shrinkvector_ (lua_State *L, void *block, int *size, |
| 129 | int final_n, int size_elem) { |
| 130 | void *newblock; |
| 131 | size_t oldsize = cast_sizet((*size) * size_elem); |
| 132 | size_t newsize = cast_sizet(final_n * size_elem); |
| 133 | lua_assert(newsize <= oldsize); |
| 134 | newblock = luaM_saferealloc_(L, block, oldsize, newsize); |
| 135 | *size = final_n; |
| 136 | return newblock; |
| 137 | } |
| 138 | |
| 139 | /* }================================================================== */ |
| 140 |
nothing calls this directly
no test coverage detected