Navigation Menu

Skip to content

Commit

Permalink
Fix incorrect capacity adjustment in Oevent list
Browse files Browse the repository at this point in the history
Was capped at 16 instead of properly growing as it should have.
  • Loading branch information
cancel committed Sep 13, 2019
1 parent fd0c4b9 commit 2b722c0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion bank.c
Expand Up @@ -20,7 +20,10 @@ void oevent_list_copy(Oevent_list const* src, Oevent_list* dest) {
Oevent* oevent_list_alloc_item(Oevent_list* olist) {
Usz count = olist->count;
if (olist->capacity == count) {
Usz capacity = count < 16 ? 16 : orca_round_up_power2(count);
// Note: no overflow check, but you're probably out of memory if this
// happens anyway. Like other uses of realloc in orca, we also don't check
// for a failed allocation.
Usz capacity = count < 16 ? 16 : orca_round_up_power2(count + 1);
olist->buffer = realloc(olist->buffer, capacity * sizeof(Oevent));
olist->capacity = capacity;
}
Expand Down

0 comments on commit 2b722c0

Please sign in to comment.