resizable: Fix capacity growing
This commit is contained in:
parent
09d51b9080
commit
f907461b90
1 changed files with 2 additions and 2 deletions
|
|
@ -42,12 +42,12 @@ apfl_resizable_grow_cap(size_t elem_size, void **mem, size_t *len, size_t *cap,
|
|||
return true;
|
||||
}
|
||||
|
||||
size_t newcap = *cap + elem_size * inc_cap;
|
||||
size_t newcap = *cap + inc_cap;
|
||||
|
||||
// TODO: We currently simply grow the memory to have space for exactly
|
||||
// inc_cap more elements. It would probably be smarter to grow the
|
||||
// memory a bit larger to reduce calls to realloc.
|
||||
void *newmem = realloc(*mem, newcap);
|
||||
void *newmem = realloc(*mem, newcap * elem_size);
|
||||
if (newmem == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue