summaryrefslogtreecommitdiffstats
path: root/zix
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2018-11-14 01:21:25 +0100
committerDavid Robillard <d@drobilla.net>2018-11-14 12:10:06 +0100
commitf928e67b46bca4922532d909bddd116f3d991179 (patch)
tree37ded66bd0f3d5bdab9591f0beee5e4131bf07ec /zix
parentaefc020257e5cf89ecec036a33ef1637297cecf7 (diff)
downloadzix-f928e67b46bca4922532d909bddd116f3d991179.tar.gz
zix-f928e67b46bca4922532d909bddd116f3d991179.tar.bz2
zix-f928e67b46bca4922532d909bddd116f3d991179.zip
Make comparator functions take const user data
Diffstat (limited to 'zix')
-rw-r--r--zix/btree.c4
-rw-r--r--zix/btree.h4
-rw-r--r--zix/common.h4
3 files changed, 7 insertions, 5 deletions
diff --git a/zix/btree.c b/zix/btree.c
index 78a5a0d..f337f7d 100644
--- a/zix/btree.c
+++ b/zix/btree.c
@@ -36,7 +36,7 @@ struct ZixBTreeImpl {
ZixBTreeNode* root;
ZixDestroyFunc destroy;
ZixComparator cmp;
- void* cmp_data;
+ const void* cmp_data;
size_t size;
unsigned height; ///< Number of levels, i.e. root only has height 1
};
@@ -109,7 +109,7 @@ zix_btree_node_new(const bool leaf)
ZIX_API ZixBTree*
zix_btree_new(const ZixComparator cmp,
- void* const cmp_data,
+ const void* const cmp_data,
const ZixDestroyFunc destroy)
{
ZixBTree* t = (ZixBTree*)malloc(sizeof(ZixBTree));
diff --git a/zix/btree.h b/zix/btree.h
index 29c01d3..46daa24 100644
--- a/zix/btree.h
+++ b/zix/btree.h
@@ -1,5 +1,5 @@
/*
- Copyright 2011-2014 David Robillard <http://drobilla.net>
+ Copyright 2011-2016 David Robillard <http://drobilla.net>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
@@ -57,7 +57,7 @@ typedef struct ZixBTreeIterImpl ZixBTreeIter;
*/
ZIX_API ZixBTree*
zix_btree_new(ZixComparator cmp,
- void* cmp_data,
+ const void* cmp_data,
ZixDestroyFunc destroy);
/**
diff --git a/zix/common.h b/zix/common.h
index 71e8a22..a59c033 100644
--- a/zix/common.h
+++ b/zix/common.h
@@ -86,7 +86,9 @@ zix_strerror(const ZixStatus status)
/**
Function for comparing two elements.
*/
-typedef int (*ZixComparator)(const void* a, const void* b, void* user_data);
+typedef int (*ZixComparator)(const void* a,
+ const void* b,
+ const void* user_data);
/**
Function for testing equality of two elements.