diff options
author | David Robillard <d@drobilla.net> | 2025-06-07 11:59:01 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2025-06-07 11:59:01 -0400 |
commit | 9893392b37b2e545780b790074a83d2f52eb881c (patch) | |
tree | 8a7fbe73940dd0e63e66500342f07907092b246e | |
parent | eb77a3da8668d974277682a5000185fc5fcf6ceb (diff) | |
download | zix-9893392b37b2e545780b790074a83d2f52eb881c.tar.gz zix-9893392b37b2e545780b790074a83d2f52eb881c.tar.bz2 zix-9893392b37b2e545780b790074a83d2f52eb881c.zip |
Fix word size calculation in BTree implementation
-rw-r--r-- | src/btree.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/btree.c b/src/btree.c index 61fbaa7..dabd406 100644 --- a/src/btree.c +++ b/src/btree.c @@ -14,9 +14,9 @@ // #define ZIX_BTREE_SORTED_CHECK 1 // Define ZixShort as an integer type half the size of a pointer -#if UINTPTR_MAX >= UINT32_MAX +#if UINTPTR_MAX > UINT32_MAX // 64-bit typedef uint32_t ZixShort; -#else +#else // 32-bit typedef uint16_t ZixShort; #endif @@ -218,7 +218,7 @@ zix_btree_split_child(ZixAllocator* const allocator, assert(i < n->n_vals + 1U); assert(zix_btree_child(n, i) == lhs); - const ZixShort max_n_vals = zix_btree_max_vals(lhs); + const unsigned max_n_vals = zix_btree_max_vals(lhs); ZixBTreeNode* rhs = zix_btree_node_new(allocator, lhs->is_leaf); if (!rhs) { return NULL; @@ -492,8 +492,9 @@ zix_btree_insert(ZixBTree* const t, void* const e) static void zix_btree_iter_set_frame(ZixBTreeIter* const ti, ZixBTreeNode* const n, - const ZixShort i) + const unsigned i) { + assert(i <= UINT16_MAX); ti->nodes[ti->level] = n; ti->indexes[ti->level] = (uint16_t)i; } |