mirror of
https://github.com/borgbackup/borg.git
synced 2024-12-25 01:06:50 +00:00
hashindex.c: hashindex_resize check hashindex_set rc (contract)
This commit is contained in:
parent
5d2dbffbcd
commit
02bb79dcbb
1 changed files with 7 additions and 1 deletions
|
@ -100,6 +100,8 @@ static int hashindex_delete(HashIndex *index, const void *key);
|
||||||
static void *hashindex_next_key(HashIndex *index, const void *key);
|
static void *hashindex_next_key(HashIndex *index, const void *key);
|
||||||
|
|
||||||
/* Private API */
|
/* Private API */
|
||||||
|
static void hashindex_free(HashIndex *index);
|
||||||
|
|
||||||
static int
|
static int
|
||||||
hashindex_index(HashIndex *index, const void *key)
|
hashindex_index(HashIndex *index, const void *key)
|
||||||
{
|
{
|
||||||
|
@ -148,7 +150,11 @@ hashindex_resize(HashIndex *index, int capacity)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
while((key = hashindex_next_key(index, key))) {
|
while((key = hashindex_next_key(index, key))) {
|
||||||
hashindex_set(new, key, key + key_size);
|
if(!hashindex_set(new, key, key + key_size)) {
|
||||||
|
/* This can only happen if there's a bug in the code calculating capacity */
|
||||||
|
hashindex_free(new);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
free(index->buckets);
|
free(index->buckets);
|
||||||
index->buckets = new->buckets;
|
index->buckets = new->buckets;
|
||||||
|
|
Loading…
Reference in a new issue