summaryrefslogtreecommitdiffstats
path: root/lib
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
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')
-rw-r--r--lib/distribute.c4
-rw-r--r--lib/hash.c78
-rw-r--r--lib/hash.h22
-rw-r--r--lib/if_rmap.c2
-rw-r--r--lib/routemap.c12
-rw-r--r--lib/thread.c8
6 files changed, 63 insertions, 63 deletions
diff --git a/lib/distribute.c b/lib/distribute.c
index 3a6b775bc..7cc10a230 100644
--- a/lib/distribute.c
+++ b/lib/distribute.c
@@ -409,7 +409,7 @@ int config_show_distribute(struct vty *vty, struct distribute_ctx *dist_ctxt)
{
unsigned int i;
int has_print = 0;
- struct hash_backet *mp;
+ struct hash_bucket *mp;
struct distribute *dist;
/* Output filter configuration. */
@@ -512,7 +512,7 @@ int config_write_distribute(struct vty *vty,
unsigned int i;
int j;
int output, v6;
- struct hash_backet *mp;
+ struct hash_bucket *mp;
int write = 0;
for (i = 0; i < dist_ctxt->disthash->size; i++)
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;
diff --git a/lib/hash.h b/lib/hash.h
index 8c695d238..2bb0ada9f 100644
--- a/lib/hash.h
+++ b/lib/hash.h
@@ -39,15 +39,15 @@ DECLARE_MTYPE(HASH_BACKET)
#define HASHWALK_CONTINUE 0
#define HASHWALK_ABORT -1
-struct hash_backet {
+struct hash_bucket {
/*
- * if this backet is the head of the linked listed, len denotes the
+ * if this bucket is the head of the linked listed, len denotes the
* number of elements in the list
*/
int len;
/* Linked list. */
- struct hash_backet *next;
+ struct hash_bucket *next;
/* Hash key. */
unsigned int key;
@@ -64,8 +64,8 @@ struct hashstats {
};
struct hash {
- /* Hash backet. */
- struct hash_backet **index;
+ /* Hash bucket. */
+ struct hash_bucket **index;
/* Hash table size. Must be power of 2 */
unsigned int size;
@@ -172,9 +172,9 @@ hash_create_size(unsigned int size, unsigned int (*hash_key)(void *),
* hash table to operate on
*
* data
- * data to insert or retrieve - A hash backet will not be created if
+ * data to insert or retrieve - A hash bucket will not be created if
* the alloc_func returns a NULL pointer and nothing will be added to
- * the hash. As such backet->data will always be non-NULL.
+ * the hash. As such bucket->data will always be non-NULL.
*
* alloc_func
* function to call if the item is not found in the hash table. This
@@ -243,7 +243,7 @@ extern void *hash_release(struct hash *hash, void *data);
* during the walk will cause undefined behavior in that some new entries
* will be walked and some will not. So do not do this.
*
- * The backet passed to func will have a non-NULL data pointer.
+ * The bucket passed to func will have a non-NULL data pointer.
*
* hash
* hash table to operate on
@@ -255,7 +255,7 @@ extern void *hash_release(struct hash *hash, void *data);
* arbitrary argument passed as the second parameter in each call to 'func'
*/
extern void hash_iterate(struct hash *hash,
- void (*func)(struct hash_backet *, void *), void *arg);
+ void (*func)(struct hash_bucket *, void *), void *arg);
/*
* Iterate over the elements in a hash table, stopping on condition.
@@ -265,7 +265,7 @@ extern void hash_iterate(struct hash *hash,
* during the walk will cause undefined behavior in that some new entries
* will be walked and some will not. So do not do this.
*
- * The backet passed to func will have a non-NULL data pointer.
+ * The bucket passed to func will have a non-NULL data pointer.
*
* hash
* hash table to operate on
@@ -278,7 +278,7 @@ extern void hash_iterate(struct hash *hash,
* arbitrary argument passed as the second parameter in each call to 'func'
*/
extern void hash_walk(struct hash *hash,
- int (*func)(struct hash_backet *, void *), void *arg);
+ int (*func)(struct hash_bucket *, void *), void *arg);
/*
* Remove all elements from a hash table.
diff --git a/lib/if_rmap.c b/lib/if_rmap.c
index 69da695dc..7ac536817 100644
--- a/lib/if_rmap.c
+++ b/lib/if_rmap.c
@@ -261,7 +261,7 @@ DEFUN (no_if_rmap,
int config_write_if_rmap(struct vty *vty)
{
unsigned int i;
- struct hash_backet *mp;
+ struct hash_bucket *mp;
int write = 0;
for (i = 0; i < ifrmaphash->size; i++)
diff --git a/lib/routemap.c b/lib/routemap.c
index 61e597520..7c1ee2353 100644
--- a/lib/routemap.c
+++ b/lib/routemap.c
@@ -1664,9 +1664,9 @@ static bool route_map_dep_hash_cmp(const void *p1, const void *p2)
== 0);
}
-static void route_map_clear_reference(struct hash_backet *backet, void *arg)
+static void route_map_clear_reference(struct hash_bucket *bucket, void *arg)
{
- struct route_map_dep *dep = (struct route_map_dep *)backet->data;
+ struct route_map_dep *dep = (struct route_map_dep *)bucket->data;
char *rmap_name;
if (arg) {
@@ -1720,9 +1720,9 @@ static unsigned int route_map_dep_hash_make_key(void *p)
return (string_hash_make((char *)p));
}
-static void route_map_print_dependency(struct hash_backet *backet, void *data)
+static void route_map_print_dependency(struct hash_bucket *bucket, void *data)
{
- char *rmap_name = (char *)backet->data;
+ char *rmap_name = (char *)bucket->data;
char *dep_name = (char *)data;
zlog_debug("%s: Dependency for %s: %s", __FUNCTION__, dep_name,
@@ -1846,9 +1846,9 @@ static struct hash *route_map_get_dep_hash(route_map_event_t event)
return (upd8_hash);
}
-static void route_map_process_dependency(struct hash_backet *backet, void *data)
+static void route_map_process_dependency(struct hash_bucket *bucket, void *data)
{
- char *rmap_name = (char *)backet->data;
+ char *rmap_name = (char *)bucket->data;
route_map_event_t type = (route_map_event_t)(ptrdiff_t)data;
if (rmap_debug)
diff --git a/lib/thread.c b/lib/thread.c
index 8c1b3ff06..055587434 100644
--- a/lib/thread.c
+++ b/lib/thread.c
@@ -106,7 +106,7 @@ static void vty_out_cpu_thread_history(struct vty *vty,
a->types & (1 << THREAD_EXECUTE) ? 'X' : ' ', a->funcname);
}
-static void cpu_record_hash_print(struct hash_backet *bucket, void *args[])
+static void cpu_record_hash_print(struct hash_bucket *bucket, void *args[])
{
struct cpu_thread_history *totals = args[0];
struct cpu_thread_history copy;
@@ -178,7 +178,7 @@ static void cpu_record_print(struct vty *vty, uint8_t filter)
if (m->cpu_record->count)
hash_iterate(
m->cpu_record,
- (void (*)(struct hash_backet *,
+ (void (*)(struct hash_bucket *,
void *))cpu_record_hash_print,
args);
else
@@ -202,7 +202,7 @@ static void cpu_record_print(struct vty *vty, uint8_t filter)
vty_out_cpu_thread_history(vty, &tmp);
}
-static void cpu_record_hash_clear(struct hash_backet *bucket, void *args[])
+static void cpu_record_hash_clear(struct hash_bucket *bucket, void *args[])
{
uint8_t *filter = args[0];
struct hash *cpu_record = args[1];
@@ -229,7 +229,7 @@ static void cpu_record_clear(uint8_t filter)
void *args[2] = {tmp, m->cpu_record};
hash_iterate(
m->cpu_record,
- (void (*)(struct hash_backet *,
+ (void (*)(struct hash_bucket *,
void *))cpu_record_hash_clear,
args);
}