Skip to content

Commit

Permalink
Fix bug with tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
pelijah committed May 12, 2024
1 parent 47652c6 commit 505ccb1
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions librz/util/ht/ht_inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,32 +187,38 @@ static HT_(Kv) *internal_ht_grow(HtName_(Ht) *ht, HT_(Kv) *tracked) {
return tracked;
}

HT_(Kv) *new = NULL;
for (ut32 i = 0; i < ht->size; i++) {
HT_(Bucket) *bt = &ht->table[i];
HT_(Kv) *kv;
ut32 j;

BUCKET_FOREACH(ht, bt, j, kv) {
HT_(Status) status;
if (!Ht_(insert_kv)(ht2, kv, false, &status)) {
if (kv == tracked) {
continue;
}
if (!Ht_(insert_kv)(ht2, kv, false, NULL)) {
ht2->opt.finiKV = NULL;
Ht_(free)(ht2);
return tracked;
}
if (!new && kv == tracked) {
new = status.kv;
}
}
}
HT_(Status) status;
if (!Ht_(insert_kv)(ht2, tracked, false, &status)) {
ht2->opt.finiKV = NULL;
Ht_(free)(ht2);
return tracked;
}
tracked = status.kv;

// And now swap the internals.
HtName_(Ht) swap = *ht;
*ht = *ht2;
*ht2 = swap;

ht2->opt.finiKV = NULL;
Ht_(free)(ht2);
return new;
return tracked;
}

static HT_(Kv) *check_growing(HtName_(Ht) *ht, HT_(Kv) *tracked) {
Expand Down

0 comments on commit 505ccb1

Please sign in to comment.