summaryrefslogtreecommitdiffstats
path: root/src/btree.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2021-09-14 17:19:12 -0400
committerDavid Robillard <d@drobilla.net>2021-09-14 17:19:12 -0400
commit19235b7127bcf5597fb0436deb45c2e6af5843c6 (patch)
treebb0207a4799f67933cd793e0501d09a10822c5ec /src/btree.c
parent9572ea596d07147dbfb6db7772623e740ce28652 (diff)
downloadzix-19235b7127bcf5597fb0436deb45c2e6af5843c6.tar.gz
zix-19235b7127bcf5597fb0436deb45c2e6af5843c6.tar.bz2
zix-19235b7127bcf5597fb0436deb45c2e6af5843c6.zip
Make ZixAllocator a single flat struct
I can never decide between these two patterns for polymorphic objects in C, but this one seems more appropriate here since it's more conducive to inheritance.
Diffstat (limited to 'src/btree.c')
-rw-r--r--src/btree.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/btree.c b/src/btree.c
index a73a2d0..869b98a 100644
--- a/src/btree.c
+++ b/src/btree.c
@@ -25,11 +25,11 @@ typedef uint16_t ZixShort;
#define ZIX_BTREE_INODE_VALS (ZIX_BTREE_LEAF_VALS / 2u)
struct ZixBTreeImpl {
- const ZixAllocator* allocator;
- ZixBTreeNode* root;
- ZixComparator cmp;
- const void* cmp_data;
- size_t size;
+ ZixAllocator* allocator;
+ ZixBTreeNode* root;
+ ZixComparator cmp;
+ const void* cmp_data;
+ size_t size;
};
struct ZixBTreeNodeImpl {
@@ -57,7 +57,7 @@ static_assert(sizeof(ZixBTreeNode) >=
#endif
static ZixBTreeNode*
-zix_btree_node_new(const ZixAllocator* const allocator, const bool leaf)
+zix_btree_node_new(ZixAllocator* const allocator, const bool leaf)
{
#if !((defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112l) || \
(defined(__cplusplus) && __cplusplus >= 201103L))
@@ -87,9 +87,9 @@ zix_btree_child(const ZixBTreeNode* const node, const unsigned i)
}
ZixBTree*
-zix_btree_new(const ZixAllocator* const allocator,
- const ZixComparator cmp,
- const void* const cmp_data)
+zix_btree_new(ZixAllocator* const allocator,
+ const ZixComparator cmp,
+ const void* const cmp_data)
{
assert(cmp);
@@ -203,10 +203,10 @@ zix_btree_aerase(void** const array, const unsigned n, const unsigned i)
/// Split lhs, the i'th child of `n`, into two nodes
static ZixBTreeNode*
-zix_btree_split_child(const ZixAllocator* const allocator,
- ZixBTreeNode* const n,
- const unsigned i,
- ZixBTreeNode* const lhs)
+zix_btree_split_child(ZixAllocator* const allocator,
+ ZixBTreeNode* const n,
+ const unsigned i,
+ ZixBTreeNode* const lhs)
{
assert(lhs->n_vals == zix_btree_max_vals(lhs));
assert(n->n_vals < ZIX_BTREE_INODE_VALS);