diff options
author | Simon Huang <xing.huang@ai-baby.com> | 2018-08-15 23:58:52 +0800 |
---|---|---|
committer | Garrett D'Amore <garrett@damore.org> | 2018-08-15 20:58:52 +0500 |
commit | f9ca0adb51e3c1e8c1b990abb5a827bb9e05fbc4 (patch) | |
tree | b44a9e137cd737646ea729ea9b86c282b6e4934b | |
parent | e7f8a751316b942d8962cd0232c2d606c1d9a9db (diff) | |
download | nanomsg-f9ca0adb51e3c1e8c1b990abb5a827bb9e05fbc4.tar.gz |
Fix some format issues in src/utils/hash.c (#988)
-rw-r--r-- | src/utils/hash.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/utils/hash.c b/src/utils/hash.c index 8ffe3e2..15135e9 100644 --- a/src/utils/hash.c +++ b/src/utils/hash.c @@ -52,7 +52,8 @@ void nn_hash_term (struct nn_hash *self) nn_free (self->array); } -static void nn_hash_rehash (struct nn_hash *self) { +static void nn_hash_rehash (struct nn_hash *self) +{ uint32_t i; uint32_t oldslots; struct nn_list *oldarray; @@ -66,27 +67,26 @@ static void nn_hash_rehash (struct nn_hash *self) { self->array = nn_alloc (sizeof (struct nn_list) * self->slots, "hash map"); alloc_assert (self->array); for (i = 0; i != self->slots; ++i) - nn_list_init (&self->array [i]); + nn_list_init (&self->array [i]); /* Move the items from old slot array to new slot array. */ for (i = 0; i != oldslots; ++i) { - while (!nn_list_empty (&oldarray [i])) { - hitm = nn_cont (nn_list_begin (&oldarray [i]), - struct nn_hash_item, list); - nn_list_erase (&oldarray [i], &hitm->list); - newslot = nn_hash_key (hitm->key) % self->slots; - nn_list_insert (&self->array [newslot], &hitm->list, - nn_list_end (&self->array [newslot])); - } - - nn_list_term (&oldarray [i]); + while (!nn_list_empty (&oldarray [i])) { + hitm = nn_cont (nn_list_begin (&oldarray [i]), + struct nn_hash_item, list); + nn_list_erase (&oldarray [i], &hitm->list); + newslot = nn_hash_key (hitm->key) % self->slots; + nn_list_insert (&self->array [newslot], &hitm->list, + nn_list_end (&self->array [newslot])); + } + + nn_list_term (&oldarray [i]); } /* Deallocate the old array of slots. */ nn_free (oldarray); } - void nn_hash_insert (struct nn_hash *self, uint32_t key, struct nn_hash_item *item) { @@ -108,7 +108,7 @@ void nn_hash_insert (struct nn_hash *self, uint32_t key, /* If the hash is getting full, double the amount of slots and re-hash all the items. */ if (nn_slow (self->items * 2 > self->slots && self->slots < 0x80000000)) - nn_hash_rehash(self); + nn_hash_rehash(self); } void nn_hash_erase (struct nn_hash *self, struct nn_hash_item *item) |