** 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. */
| 108 | ** error. |
| 109 | */ |
| 110 | void *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 |
nothing calls this directly
no test coverage detected