summaryrefslogtreecommitdiffstats
path: root/lib/hash.c
diff options
context:
space:
mode:
authorTim Bray <tim@kooky.org>2019-02-19 16:46:52 +0100
committerQuentin Young <qlyoung@cumulusnetworks.com>2019-02-25 17:22:36 +0100
commite3b78da875d7ccb744763bb9f8ef6d08655e3975 (patch)
tree58e77a2f68461230e8283624c73cd9a7827e5aa1 /lib/hash.c
parentMerge pull request #3856 from donaldsharp/dplane_use_after_free (diff)
downloadfrr-e3b78da875d7ccb744763bb9f8ef6d08655e3975.tar.xz
frr-e3b78da875d7ccb744763bb9f8ef6d08655e3975.zip
*: Rename backet to bucket
Presume typo from original author Signed-off-by: Tim Bray <tim@kooky.org>
Diffstat (limited to 'lib/hash.c')
-rw-r--r--lib/hash.c78
1 files changed, 39 insertions, 39 deletions
diff --git a/lib/hash.c b/lib/hash.c
index 6c3c953e9..9f9fc31d3 100644
--- a/lib/hash.c
+++ b/lib/hash.c
@@ -46,7 +46,7 @@ struct hash *hash_create_size(unsigned int size,
assert((size & (size - 1)) == 0);
hash = XCALLOC(MTYPE_HASH, sizeof(struct hash));
hash->index =
- XCALLOC(MTYPE_HASH_INDEX, sizeof(struct hash_backet *) * size);
+ XCALLOC(MTYPE_HASH_INDEX, sizeof(struct hash_bucket *) * size);
hash->size = size;
hash->hash_key = hash_key;
hash->hash_cmp = hash_cmp;
@@ -86,7 +86,7 @@ void *hash_alloc_intern(void *arg)
static void hash_expand(struct hash *hash)
{
unsigned int i, new_size;
- struct hash_backet *hb, *hbnext, **new_index;
+ struct hash_bucket *hb, *hbnext, **new_index;
new_size = hash->size * 2;
@@ -94,7 +94,7 @@ static void hash_expand(struct hash *hash)
return;
new_index = XCALLOC(MTYPE_HASH_INDEX,
- sizeof(struct hash_backet *) * new_size);
+ sizeof(struct hash_bucket *) * new_size);
if (new_index == NULL)
return;
@@ -133,7 +133,7 @@ void *hash_get(struct hash *hash, void *data, void *(*alloc_func)(void *))
unsigned int key;
unsigned int index;
void *newdata;
- struct hash_backet *backet;
+ struct hash_bucket *bucket;
if (!alloc_func && !hash->count)
return NULL;
@@ -141,10 +141,10 @@ void *hash_get(struct hash *hash, void *data, void *(*alloc_func)(void *))
key = (*hash->hash_key)(data);
index = key & (hash->size - 1);
- for (backet = hash->index[index]; backet != NULL;
- backet = backet->next) {
- if (backet->key == key && (*hash->hash_cmp)(backet->data, data))
- return backet->data;
+ for (bucket = hash->index[index]; bucket != NULL;
+ bucket = bucket->next) {
+ if (bucket->key == key && (*hash->hash_cmp)(bucket->data, data))
+ return bucket->data;
}
if (alloc_func) {
@@ -157,26 +157,26 @@ void *hash_get(struct hash *hash, void *data, void *(*alloc_func)(void *))
index = key & (hash->size - 1);
}
- backet = XCALLOC(MTYPE_HASH_BACKET, sizeof(struct hash_backet));
- backet->data = newdata;
- backet->key = key;
- backet->next = hash->index[index];
- hash->index[index] = backet;
+ bucket = XCALLOC(MTYPE_HASH_BACKET, sizeof(struct hash_bucket));
+ bucket->data = newdata;
+ bucket->key = key;
+ bucket->next = hash->index[index];
+ hash->index[index] = bucket;
hash->count++;
- int oldlen = backet->next ? backet->next->len : 0;
+ int oldlen = bucket->next ? bucket->next->len : 0;
int newlen = oldlen + 1;
if (newlen == 1)
hash->stats.empty--;
else
- backet->next->len = 0;
+ bucket->next->len = 0;
- backet->len = newlen;
+ bucket->len = newlen;
hash_update_ssq(hash, oldlen, newlen);
- return backet->data;
+ return bucket->data;
}
return NULL;
}
@@ -201,22 +201,22 @@ void *hash_release(struct hash *hash, void *data)
void *ret;
unsigned int key;
unsigned int index;
- struct hash_backet *backet;
- struct hash_backet *pp;
+ struct hash_bucket *bucket;
+ struct hash_bucket *pp;
key = (*hash->hash_key)(data);
index = key & (hash->size - 1);
- for (backet = pp = hash->index[index]; backet; backet = backet->next) {
- if (backet->key == key
- && (*hash->hash_cmp)(backet->data, data)) {
+ for (bucket = pp = hash->index[index]; bucket; bucket = bucket->next) {
+ if (bucket->key == key
+ && (*hash->hash_cmp)(bucket->data, data)) {
int oldlen = hash->index[index]->len;
int newlen = oldlen - 1;
- if (backet == pp)
- hash->index[index] = backet->next;
+ if (bucket == pp)
+ hash->index[index] = bucket->next;
else
- pp->next = backet->next;
+ pp->next = bucket->next;
if (hash->index[index])
hash->index[index]->len = newlen;
@@ -225,26 +225,26 @@ void *hash_release(struct hash *hash, void *data)
hash_update_ssq(hash, oldlen, newlen);
- ret = backet->data;
- XFREE(MTYPE_HASH_BACKET, backet);
+ ret = bucket->data;
+ XFREE(MTYPE_HASH_BACKET, bucket);
hash->count--;
return ret;
}
- pp = backet;
+ pp = bucket;
}
return NULL;
}
-void hash_iterate(struct hash *hash, void (*func)(struct hash_backet *, void *),
+void hash_iterate(struct hash *hash, void (*func)(struct hash_bucket *, void *),
void *arg)
{
unsigned int i;
- struct hash_backet *hb;
- struct hash_backet *hbnext;
+ struct hash_bucket *hb;
+ struct hash_bucket *hbnext;
for (i = 0; i < hash->size; i++)
for (hb = hash->index[i]; hb; hb = hbnext) {
- /* get pointer to next hash backet here, in case (*func)
+ /* get pointer to next hash bucket here, in case (*func)
* decides to delete hb by calling hash_release
*/
hbnext = hb->next;
@@ -252,17 +252,17 @@ void hash_iterate(struct hash *hash, void (*func)(struct hash_backet *, void *),
}
}
-void hash_walk(struct hash *hash, int (*func)(struct hash_backet *, void *),
+void hash_walk(struct hash *hash, int (*func)(struct hash_bucket *, void *),
void *arg)
{
unsigned int i;
- struct hash_backet *hb;
- struct hash_backet *hbnext;
+ struct hash_bucket *hb;
+ struct hash_bucket *hbnext;
int ret = HASHWALK_CONTINUE;
for (i = 0; i < hash->size; i++) {
for (hb = hash->index[i]; hb; hb = hbnext) {
- /* get pointer to next hash backet here, in case (*func)
+ /* get pointer to next hash bucket here, in case (*func)
* decides to delete hb by calling hash_release
*/
hbnext = hb->next;
@@ -276,8 +276,8 @@ void hash_walk(struct hash *hash, int (*func)(struct hash_backet *, void *),
void hash_clean(struct hash *hash, void (*free_func)(void *))
{
unsigned int i;
- struct hash_backet *hb;
- struct hash_backet *next;
+ struct hash_bucket *hb;
+ struct hash_bucket *next;
for (i = 0; i < hash->size; i++) {
for (hb = hash->index[i]; hb; hb = next) {
@@ -296,7 +296,7 @@ void hash_clean(struct hash *hash, void (*free_func)(void *))
hash->stats.empty = hash->size;
}
-static void hash_to_list_iter(struct hash_backet *hb, void *arg)
+static void hash_to_list_iter(struct hash_bucket *hb, void *arg)
{
struct list *list = arg;