Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/shared/hash.c b/shared/hash.c
- index ab8534a..18898ac 100644
- --- a/shared/hash.c
- +++ b/shared/hash.c
- @@ -137,8 +137,7 @@ static inline unsigned int hash_superfast(const char *key, unsigned int len)
- return hash;
- }
- -static struct hash_entry *hash_add_entry(struct hash *hash,
- - const char *key, const void *value)
- +static struct hash_entry *hash_add_entry(struct hash *hash, const char *key)
- {
- unsigned int keylen = strlen(key);
- unsigned int hashval = hash_superfast(key, keylen);
- @@ -172,7 +171,8 @@ static struct hash_entry *hash_add_entry(struct hash *hash,
- bucket->used++;
- hash->count++;
- - entry->key = entry->value = NULL;
- + entry->key = NULL;
- + entry->value = NULL;
- return entry;
- }
- @@ -185,12 +185,12 @@ static struct hash_entry *hash_add_entry(struct hash *hash,
- */
- int hash_add(struct hash *hash, const char *key, const void *value)
- {
- - struct hash_entry *entry = hash_add_entry(hash, key, value);
- + struct hash_entry *entry = hash_add_entry(hash, key);
- if (!entry)
- return -errno;
- - if (hash->free_value)
- + if (hash->free_value && entry->value != NULL)
- hash->free_value((void *)entry->value);
- entry->key = key;
- @@ -202,12 +202,12 @@ int hash_add(struct hash *hash, const char *key, const void *value)
- /* similar to hash_add(), but fails if key already exists */
- int hash_add_unique(struct hash *hash, const char *key, const void *value)
- {
- - struct hash_entry *entry = hash_add_entry(hash, key, value);
- + struct hash_entry *entry = hash_add_entry(hash, key);
- if (!entry)
- return -errno;
- - if (entry->key || entry->value)
- + if (entry->key)
- return -EEXIST;
- entry->key = key;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement