fix: handle realloc to zero capacity
* Call stk_module_free_memory() when new_capacity is 0.
This commit is contained in:
@@ -195,6 +195,11 @@ int stk_module_realloc_memory(size_t new_capacity)
|
|||||||
stk_module_func *old_inits = stk_inits;
|
stk_module_func *old_inits = stk_inits;
|
||||||
stk_module_func *old_shutdowns = stk_shutdowns;
|
stk_module_func *old_shutdowns = stk_shutdowns;
|
||||||
|
|
||||||
|
if (new_capacity == 0) {
|
||||||
|
stk_module_free_memory();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
new_module_ids =
|
new_module_ids =
|
||||||
realloc(stk_module_ids, new_capacity * sizeof(*stk_module_ids));
|
realloc(stk_module_ids, new_capacity * sizeof(*stk_module_ids));
|
||||||
new_handles = realloc(stk_handles, new_capacity * sizeof(*new_handles));
|
new_handles = realloc(stk_handles, new_capacity * sizeof(*new_handles));
|
||||||
|
|||||||
Reference in New Issue
Block a user