summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.clang-format1
-rw-r--r--include/zix/common.h5
-rw-r--r--src/btree.c63
-rw-r--r--src/tree.c21
4 files changed, 28 insertions, 62 deletions
diff --git a/.clang-format b/.clang-format
index d2c0991..dc17e38 100644
--- a/.clang-format
+++ b/.clang-format
@@ -20,7 +20,6 @@ StatementMacros:
- ZIX_CONST_API
- ZIX_CONST_API
- ZIX_MALLOC_API
- - ZIX_PRIVATE
- ZIX_PURE_API
- ZIX_UNUSED
...
diff --git a/include/zix/common.h b/include/zix/common.h
index 865d232..0191cca 100644
--- a/include/zix/common.h
+++ b/include/zix/common.h
@@ -38,13 +38,8 @@
# else
# define ZIX_API ZIX_LIB_IMPORT
# endif
-# define ZIX_PRIVATE static
-#elif defined(ZIX_INLINE)
-# define ZIX_API static inline
-# define ZIX_PRIVATE static inline
#else
# define ZIX_API
-# define ZIX_PRIVATE static
#endif
#ifdef __GNUC__
diff --git a/src/btree.c b/src/btree.c
index 7435445..a05bcf1 100644
--- a/src/btree.c
+++ b/src/btree.c
@@ -75,8 +75,7 @@ struct ZixBTreeIterImpl {
#ifdef ZIX_BTREE_DEBUG
-ZIX_PRIVATE
-void
+static void
print_node(const ZixBTreeNode* n, const char* prefix)
{
printf("%s[", prefix);
@@ -86,8 +85,7 @@ print_node(const ZixBTreeNode* n, const char* prefix)
printf(" ]\n");
}
-ZIX_PRIVATE
-void
+static void
print_tree(const ZixBTreeNode* parent, const ZixBTreeNode* node, int level)
{
if (node) {
@@ -111,8 +109,7 @@ print_tree(const ZixBTreeNode* parent, const ZixBTreeNode* node, int level)
#endif // ZIX_BTREE_DEBUG
-ZIX_PRIVATE
-ZixBTreeNode*
+static ZixBTreeNode*
zix_btree_node_new(const bool leaf)
{
#if !((defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112l) || \
@@ -128,16 +125,14 @@ zix_btree_node_new(const bool leaf)
return node;
}
-ZIX_PRIVATE
-void*
+static void*
zix_btree_value(const ZixBTreeNode* const node, const unsigned i)
{
assert(i < node->n_vals);
return node->is_leaf ? node->data.leaf.vals[i] : node->data.inode.vals[i];
}
-ZIX_PRIVATE
-ZixBTreeNode*
+static ZixBTreeNode*
zix_btree_child(const ZixBTreeNode* const node, const unsigned i)
{
assert(!node->is_leaf);
@@ -166,8 +161,7 @@ zix_btree_new(const ZixComparator cmp,
return t;
}
-ZIX_PRIVATE
-void
+static void
zix_btree_free_rec(ZixBTree* const t, ZixBTreeNode* const n)
{
if (n) {
@@ -208,23 +202,20 @@ zix_btree_size(const ZixBTree* const t)
return t->size;
}
-ZIX_PRIVATE
-uint16_t
+static uint16_t
zix_btree_max_vals(const ZixBTreeNode* const node)
{
return node->is_leaf ? ZIX_BTREE_LEAF_VALS : ZIX_BTREE_INODE_VALS;
}
-ZIX_PRIVATE
-uint16_t
+static uint16_t
zix_btree_min_vals(const ZixBTreeNode* const node)
{
return (uint16_t)(((zix_btree_max_vals(node) + 1U) / 2U) - 1U);
}
/** Shift pointers in `array` of length `n` right starting at `i`. */
-ZIX_PRIVATE
-void
+static void
zix_btree_ainsert(void** const array,
const unsigned n,
const unsigned i,
@@ -235,8 +226,7 @@ zix_btree_ainsert(void** const array,
}
/** Erase element `i` in `array` of length `n` and return erased element. */
-ZIX_PRIVATE
-void*
+static void*
zix_btree_aerase(void** const array, const unsigned n, const unsigned i)
{
void* const ret = array[i];
@@ -245,8 +235,7 @@ zix_btree_aerase(void** const array, const unsigned n, const unsigned i)
}
/** Split lhs, the i'th child of `n`, into two nodes. */
-ZIX_PRIVATE
-ZixBTreeNode*
+static ZixBTreeNode*
zix_btree_split_child(ZixBTreeNode* const n,
const unsigned i,
ZixBTreeNode* const lhs)
@@ -297,8 +286,7 @@ zix_btree_split_child(ZixBTreeNode* const n,
#ifdef ZIX_BTREE_SORTED_CHECK
/** Check that `n` is sorted with respect to search key `e`. */
-ZIX_PRIVATE
-bool
+static bool
zix_btree_node_is_sorted_with_respect_to(const ZixBTree* const t,
const ZixBTreeNode* const n,
const void* const e)
@@ -321,8 +309,7 @@ zix_btree_node_is_sorted_with_respect_to(const ZixBTree* const t,
#endif
/** Find the first value in `n` that is not less than `e` (lower bound). */
-ZIX_PRIVATE
-unsigned
+static unsigned
zix_btree_node_find(const ZixBTree* const t,
const ZixBTreeNode* const n,
const void* const e,
@@ -414,8 +401,7 @@ zix_btree_insert(ZixBTree* const t, void* const e)
return ZIX_STATUS_SUCCESS;
}
-ZIX_PRIVATE
-ZixBTreeIter*
+static ZixBTreeIter*
zix_btree_iter_new(const ZixBTree* const t)
{
const size_t s = t->height * sizeof(ZixBTreeIterFrame);
@@ -427,8 +413,7 @@ zix_btree_iter_new(const ZixBTree* const t)
return i;
}
-ZIX_PRIVATE
-void
+static void
zix_btree_iter_set_frame(ZixBTreeIter* const ti,
ZixBTreeNode* const n,
const unsigned i)
@@ -439,8 +424,7 @@ zix_btree_iter_set_frame(ZixBTreeIter* const ti,
}
}
-ZIX_PRIVATE
-bool
+static bool
zix_btree_node_is_minimal(ZixBTreeNode* const n)
{
assert(n->n_vals >= zix_btree_min_vals(n));
@@ -448,8 +432,7 @@ zix_btree_node_is_minimal(ZixBTreeNode* const n)
}
/** Enlarge left child by stealing a value from its right sibling. */
-ZIX_PRIVATE
-ZixBTreeNode*
+static ZixBTreeNode*
zix_btree_rotate_left(ZixBTreeNode* const parent, const unsigned i)
{
ZixBTreeNode* const lhs = zix_btree_child(parent, i);
@@ -483,8 +466,7 @@ zix_btree_rotate_left(ZixBTreeNode* const parent, const unsigned i)
}
/** Enlarge right child by stealing a value from its left sibling. */
-ZIX_PRIVATE
-ZixBTreeNode*
+static ZixBTreeNode*
zix_btree_rotate_right(ZixBTreeNode* const parent, const unsigned i)
{
ZixBTreeNode* const lhs = zix_btree_child(parent, i - 1);
@@ -518,8 +500,7 @@ zix_btree_rotate_right(ZixBTreeNode* const parent, const unsigned i)
}
/** Move n[i] down, merge the left and right child, return the merged node. */
-ZIX_PRIVATE
-ZixBTreeNode*
+static ZixBTreeNode*
zix_btree_merge(ZixBTree* const t, ZixBTreeNode* const n, const unsigned i)
{
ZixBTreeNode* const lhs = zix_btree_child(n, i);
@@ -569,8 +550,7 @@ zix_btree_merge(ZixBTree* const t, ZixBTreeNode* const n, const unsigned i)
}
/** Remove and return the min value from the subtree rooted at `n`. */
-ZIX_PRIVATE
-void*
+static void*
zix_btree_remove_min(ZixBTree* const t, ZixBTreeNode* n)
{
while (!n->is_leaf) {
@@ -592,8 +572,7 @@ zix_btree_remove_min(ZixBTree* const t, ZixBTreeNode* n)
}
/** Remove and return the max value from the subtree rooted at `n`. */
-ZIX_PRIVATE
-void*
+static void*
zix_btree_remove_max(ZixBTree* const t, ZixBTreeNode* n)
{
while (!n->is_leaf) {
diff --git a/src/tree.c b/src/tree.c
index a204baf..c2051b5 100644
--- a/src/tree.c
+++ b/src/tree.c
@@ -82,8 +82,7 @@ zix_tree_new(bool allow_duplicates,
return t;
}
-ZIX_PRIVATE
-void
+static void
zix_tree_free_rec(ZixTree* t, ZixTreeNode* n)
{
if (n) {
@@ -111,8 +110,7 @@ zix_tree_size(const ZixTree* t)
return t->size;
}
-ZIX_PRIVATE
-void
+static void
rotate(ZixTreeNode* p, ZixTreeNode* q)
{
assert(q->parent == p);
@@ -156,8 +154,7 @@ rotate(ZixTreeNode* p, ZixTreeNode* q)
* / \ / \
* B C A B
*/
-ZIX_PRIVATE
-ZixTreeNode*
+static ZixTreeNode*
rotate_left(ZixTreeNode* p, int* height_change)
{
ZixTreeNode* const q = p->right;
@@ -190,8 +187,7 @@ rotate_left(ZixTreeNode* p, int* height_change)
* A B B C
*
*/
-ZIX_PRIVATE
-ZixTreeNode*
+static ZixTreeNode*
rotate_right(ZixTreeNode* p, int* height_change)
{
ZixTreeNode* const q = p->left;
@@ -226,8 +222,7 @@ rotate_right(ZixTreeNode* p, int* height_change)
* B C
*
*/
-ZIX_PRIVATE
-ZixTreeNode*
+static ZixTreeNode*
rotate_left_right(ZixTreeNode* p, int* height_change)
{
ZixTreeNode* const q = p->left;
@@ -274,8 +269,7 @@ rotate_left_right(ZixTreeNode* p, int* height_change)
* B C
*
*/
-ZIX_PRIVATE
-ZixTreeNode*
+static ZixTreeNode*
rotate_right_left(ZixTreeNode* p, int* height_change)
{
ZixTreeNode* const q = p->right;
@@ -311,8 +305,7 @@ rotate_right_left(ZixTreeNode* p, int* height_change)
return r;
}
-ZIX_PRIVATE
-ZixTreeNode*
+static ZixTreeNode*
zix_tree_rebalance(ZixTree* t, ZixTreeNode* node, int* height_change)
{
#ifdef ZIX_TREE_HYPER_VERIFY