diff options
| author | 2026-01-12 12:13:01 +0100 | |
|---|---|---|
| committer | 2026-01-12 12:13:01 +0100 | |
| commit | 25d61ff8b5d994a02c0cc2af8e029bebd3a94cb3 (patch) | |
| tree | c64d79dff76e23704860e37e0bb45781e44e69cc | |
| parent | c74e34edda2cd76194a09e76f945cfa89dd41a79 (diff) | |
| download | libplist-25d61ff8b5d994a02c0cc2af8e029bebd3a94cb3.tar.gz libplist-25d61ff8b5d994a02c0cc2af8e029bebd3a94cb3.tar.bz2 | |
hashtable: Remove unnecessary casts by using the correct type for the `next` member
| -rw-r--r-- | src/hashtable.c | 10 | ||||
| -rw-r--r-- | src/hashtable.h | 2 |
2 files changed, 6 insertions, 6 deletions
diff --git a/src/hashtable.c b/src/hashtable.c index 86dae82..dd6dbfc 100644 --- a/src/hashtable.c +++ b/src/hashtable.c | |||
| @@ -47,7 +47,7 @@ void hash_table_destroy(hashtable_t *ht) | |||
| 47 | ht->free_func(e->value); | 47 | ht->free_func(e->value); |
| 48 | } | 48 | } |
| 49 | hashentry_t* old = e; | 49 | hashentry_t* old = e; |
| 50 | e = (hashentry_t*)e->next; | 50 | e = e->next; |
| 51 | free(old); | 51 | free(old); |
| 52 | } | 52 | } |
| 53 | } | 53 | } |
| @@ -71,7 +71,7 @@ void hash_table_insert(hashtable_t* ht, void *key, void *value) | |||
| 71 | e->value = value; | 71 | e->value = value; |
| 72 | return; | 72 | return; |
| 73 | } | 73 | } |
| 74 | e = (hashentry_t*)e->next; | 74 | e = e->next; |
| 75 | } | 75 | } |
| 76 | 76 | ||
| 77 | // if we get here, the element is not yet in the list. | 77 | // if we get here, the element is not yet in the list. |
| @@ -103,7 +103,7 @@ void* hash_table_lookup(hashtable_t* ht, void *key) | |||
| 103 | if (ht->compare_func(e->key, key)) { | 103 | if (ht->compare_func(e->key, key)) { |
| 104 | return e->value; | 104 | return e->value; |
| 105 | } | 105 | } |
| 106 | e = (hashentry_t*)e->next; | 106 | e = e->next; |
| 107 | } | 107 | } |
| 108 | return NULL; | 108 | return NULL; |
| 109 | } | 109 | } |
| @@ -124,7 +124,7 @@ void hash_table_remove(hashtable_t* ht, void *key) | |||
| 124 | // found element, remove it from the list | 124 | // found element, remove it from the list |
| 125 | hashentry_t* old = e; | 125 | hashentry_t* old = e; |
| 126 | if (e == ht->entries[idx0]) { | 126 | if (e == ht->entries[idx0]) { |
| 127 | ht->entries[idx0] = (hashentry_t*)e->next; | 127 | ht->entries[idx0] = e->next; |
| 128 | } else { | 128 | } else { |
| 129 | last->next = e->next; | 129 | last->next = e->next; |
| 130 | } | 130 | } |
| @@ -135,6 +135,6 @@ void hash_table_remove(hashtable_t* ht, void *key) | |||
| 135 | return; | 135 | return; |
| 136 | } | 136 | } |
| 137 | last = e; | 137 | last = e; |
| 138 | e = (hashentry_t*)e->next; | 138 | e = e->next; |
| 139 | } | 139 | } |
| 140 | } | 140 | } |
diff --git a/src/hashtable.h b/src/hashtable.h index 42d7b93..514cfec 100644 --- a/src/hashtable.h +++ b/src/hashtable.h | |||
| @@ -25,7 +25,7 @@ | |||
| 25 | typedef struct hashentry_t { | 25 | typedef struct hashentry_t { |
| 26 | void *key; | 26 | void *key; |
| 27 | void *value; | 27 | void *value; |
| 28 | void *next; | 28 | struct hashentry_t *next; |
| 29 | } hashentry_t; | 29 | } hashentry_t; |
| 30 | 30 | ||
| 31 | typedef unsigned int(*hash_func_t)(const void* key); | 31 | typedef unsigned int(*hash_func_t)(const void* key); |
