diff options
author | koekeishiya <aasvi93@hotmail.com> | 2017-09-23 23:24:46 +0200 |
---|---|---|
committer | koekeishiya <aasvi93@hotmail.com> | 2017-09-23 23:24:46 +0200 |
commit | df3d13c9e655c5a566d471256b5e54cca796f576 (patch) | |
tree | 03c13f16ac65b9bc102ac138448c33e869b02271 /src/hashtable.h | |
parent | eb2315cefc6c4f6375b31e93ca99f1422c78792a (diff) | |
download | skhd-df3d13c9e655c5a566d471256b5e54cca796f576.tar.gz skhd-df3d13c9e655c5a566d471256b5e54cca796f576.zip |
code style
Diffstat (limited to 'src/hashtable.h')
-rw-r--r-- | src/hashtable.h | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/hashtable.h b/src/hashtable.h index 3977b96..48ffaad 100644 --- a/src/hashtable.h +++ b/src/hashtable.h @@ -47,8 +47,8 @@ static struct bucket ** table_get_bucket(struct table *table, void *key) { struct bucket **bucket = table->buckets + (table->hash(key) % table->capacity); - while(*bucket) { - if(table->compare((*bucket)->key, key)) { + while (*bucket) { + if (table->compare((*bucket)->key, key)) { break; } bucket = &(*bucket)->next; @@ -68,9 +68,9 @@ void table_init(struct table *table, int capacity, table_hash_func hash, table_c void table_free(struct table *table) { - for(int i = 0; i < table->capacity; ++i) { + for (int i = 0; i < table->capacity; ++i) { struct bucket *next, *bucket = table->buckets[i]; - while(bucket) { + while (bucket) { next = bucket->next; free(bucket); bucket = next; @@ -88,7 +88,7 @@ void *table_find(struct table *table, void *key) void table_add(struct table *table, void *key, void *value) { struct bucket **bucket = table_get_bucket(table, key); - if(*bucket) { + if (*bucket) { (*bucket)->value = value; } else { *bucket = table_new_bucket(key, value); @@ -100,7 +100,7 @@ void *table_remove(struct table *table, void *key) { void *result = NULL; struct bucket *next, **bucket = table_get_bucket(table, key); - if(*bucket) { + if (*bucket) { result = (*bucket)->value; next = (*bucket)->next; free(*bucket); @@ -122,9 +122,9 @@ void *table_reset(struct table *table, int *count) values = malloc(sizeof(void *) * table->count); item = 0; - for(index = 0; index < capacity; ++index) { + for (index = 0; index < capacity; ++index) { struct bucket *next, **bucket = table->buckets + index; - while(*bucket) { + while (*bucket) { values[item++] = (*bucket)->value; next = (*bucket)->next; free(*bucket); |