diff options
author | Joern Engel <joern@logfs.org> | 2012-11-20 11:42:10 -0800 |
---|---|---|
committer | Joern Engel <joern@logfs.org> | 2012-11-20 11:48:04 -0800 |
commit | 9ea381132300997c2f255ff083a9f4246febc238 (patch) | |
tree | edf064819d76c7fdd040c5e43582ad4c09fcdc9d | |
parent | 839b29da920bcfebe1b9d33afeab6287b85f1d5a (diff) | |
download | cancd-9ea381132300997c2f255ff083a9f4246febc238.tar.gz |
Fix 32bit btree primitives
Using an unsigned long * to a u32 gives 32 random bits. Not a good
identifier.
Signed-off-by: Joern Engel <joern@logfs.org>
-rw-r--r-- | btree.c | 4 | ||||
-rw-r--r-- | btree.h | 14 |
2 files changed, 12 insertions, 6 deletions
@@ -664,9 +664,9 @@ void visitor32(void *elem, long opaque, unsigned long *__key, size_t index, void *__func) { visitor32_t func = __func; - u32 *key = (void *)__key; + unsigned long key = *__key; - func(elem, opaque, *key, index); + func(elem, opaque, key, index); } void visitor64(void *elem, long opaque, unsigned long *__key, size_t index, @@ -107,19 +107,25 @@ static inline void btree_init32(struct btree_head32 *head) btree_init(&head->h); } -static inline void *btree_lookup32(struct btree_head32 *head, u32 key) +static inline void *btree_lookup32(struct btree_head32 *head, u32 _key) { - return btree_lookup(&head->h, &btree_geo32, (unsigned long *)&key); + unsigned long key = _key; + + return btree_lookup(&head->h, &btree_geo32, &key); } -static inline int btree_insert32(struct btree_head32 *head, u32 key, +static inline int btree_insert32(struct btree_head32 *head, u32 _key, void *val) { + unsigned long key = _key; + return btree_insert(&head->h, &btree_geo32, (unsigned long *)&key, val); } -static inline void *btree_remove32(struct btree_head32 *head, u32 key) +static inline void *btree_remove32(struct btree_head32 *head, u32 _key) { + unsigned long key = _key; + return btree_remove(&head->h, &btree_geo32, (unsigned long *)&key); } |