summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoern Engel <joern@logfs.org>2012-11-20 11:42:10 -0800
committerJoern Engel <joern@logfs.org>2012-11-20 11:48:04 -0800
commit9ea381132300997c2f255ff083a9f4246febc238 (patch)
treeedf064819d76c7fdd040c5e43582ad4c09fcdc9d
parent839b29da920bcfebe1b9d33afeab6287b85f1d5a (diff)
downloadcancd-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.c4
-rw-r--r--btree.h14
2 files changed, 12 insertions, 6 deletions
diff --git a/btree.c b/btree.c
index af9fcc9..2c74604 100644
--- a/btree.c
+++ b/btree.c
@@ -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,
diff --git a/btree.h b/btree.h
index ad4be90..aeeaf88 100644
--- a/btree.h
+++ b/btree.h
@@ -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);
}