[RFC PATCH 6/7] btree: use void* for data

Ákos Uzonyi uzonyi.akos at gmail.com
Mon Jun 8 19:14:51 UTC 2020


---
 btree.c | 6 +++---
 btree.h | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/btree.c b/btree.c
index 7bdc687b..dd64e212 100644
--- a/btree.c
+++ b/btree.c
@@ -136,7 +136,7 @@ btree_filler(uint64_t val, uint8_t item_size)
 static uint64_t *
 btree_get_block(struct btree *b, uint64_t key, bool auto_create)
 {
-	uint64_t ***cur_block = &(b->data);
+	void **cur_block = &(b->data);
 	unsigned i;
 	uint8_t cur_depth;
 	uint8_t max_depth;
@@ -151,7 +151,7 @@ btree_get_block(struct btree *b, uint64_t key, bool auto_create)
 		sz = btree_get_block_size(b, cur_depth, max_depth);
 
 		if (*cur_block == BTREE_SET || *cur_block == BTREE_UNSET) {
-			uint64_t **old_val = *cur_block;
+			void *old_val = *cur_block;
 
 			if (!auto_create)
 				return (uint64_t *) (*cur_block);
@@ -171,7 +171,7 @@ btree_get_block(struct btree *b, uint64_t key, bool auto_create)
 			size_t pos = (key >> btree_get_block_bit_offs(b,
 				cur_depth, max_depth)) & ((1 << (sz - ptr_sz_lg)) - 1);
 
-			cur_block = (uint64_t ***) ((*cur_block) + pos);
+			cur_block = (((void **) (*cur_block)) + pos);
 		}
 	}
 
diff --git a/btree.h b/btree.h
index ed6e5249..08e8f867 100644
--- a/btree.h
+++ b/btree.h
@@ -3,8 +3,8 @@
 
 /* Simple B-tree interface */
 
-#define BTREE_SET   ((uint64_t **) ~(intptr_t) 0)
-#define BTREE_UNSET ((uint64_t **) NULL)
+#define BTREE_SET   ((void *) ~(intptr_t) 0)
+#define BTREE_UNSET ((void *) NULL)
 
 #define PTR_BLOCK_SIZE_LG_MAX   24
 #define DATA_BLOCK_SIZE_LG_MAX  23
@@ -39,7 +39,7 @@ enum btree_iterate_flags {
  */
 struct btree {
 	uint64_t set_value;         /**< Default set value */
-	uint64_t **data;
+	void *data;
 	uint8_t item_size_lg;       /**< Item size log2, in bits, 0..6. */
 	/** Pointer block size log2, in bits. 14-20, usually. */
 	uint8_t ptr_block_size_lg;
-- 
2.26.2



More information about the Strace-devel mailing list