diff options
author | David Robillard <d@drobilla.net> | 2022-11-01 23:16:39 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2022-11-16 10:22:53 -0500 |
commit | 2c309084f8b96f637c204aabb5e8edad3162ba05 (patch) | |
tree | c2f77a138eb648dae5d3b739c371aa2257518315 /src/collections.c | |
parent | ea4d4090c53ae0166f99e6af7f232705e8dc1641 (diff) | |
download | lilv-2c309084f8b96f637c204aabb5e8edad3162ba05.tar.gz lilv-2c309084f8b96f637c204aabb5e8edad3162ba05.tar.bz2 lilv-2c309084f8b96f637c204aabb5e8edad3162ba05.zip |
Switch to external zix dependency
Diffstat (limited to 'src/collections.c')
-rw-r--r-- | src/collections.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/collections.c b/src/collections.c index 10b15b0..2ea812b 100644 --- a/src/collections.c +++ b/src/collections.c @@ -5,12 +5,13 @@ #include "lilv/lilv.h" #include "sord/sord.h" -#include "zix/common.h" #include "zix/tree.h" #include <stdbool.h> #include <stddef.h> +typedef void (*LilvFreeFunc)(void* ptr); + int lilv_ptr_cmp(const void* a, const void* b, const void* user_data) { @@ -32,10 +33,18 @@ lilv_resource_node_cmp(const void* a, const void* b, const void* user_data) /* Generic collection functions */ +static void +destroy(void* const ptr, const void* const user_data) +{ + if (user_data) { + ((LilvFreeFunc)user_data)(ptr); + } +} + static inline LilvCollection* -lilv_collection_new(ZixComparator cmp, ZixDestroyFunc destructor) +lilv_collection_new(ZixTreeCompareFunc cmp, LilvFreeFunc free_func) { - return zix_tree_new(false, cmp, NULL, destructor); + return zix_tree_new(NULL, false, cmp, NULL, destroy, (const void*)free_func); } void @@ -71,28 +80,27 @@ lilv_collection_get(const LilvCollection* collection, const LilvIter* i) LilvScalePoints* lilv_scale_points_new(void) { - return lilv_collection_new(lilv_ptr_cmp, - (ZixDestroyFunc)lilv_scale_point_free); + return lilv_collection_new(lilv_ptr_cmp, (LilvFreeFunc)lilv_scale_point_free); } LilvNodes* lilv_nodes_new(void) { - return lilv_collection_new(lilv_ptr_cmp, (ZixDestroyFunc)lilv_node_free); + return lilv_collection_new(lilv_ptr_cmp, (LilvFreeFunc)lilv_node_free); } LilvUIs* lilv_uis_new(void) { return lilv_collection_new(lilv_header_compare_by_uri, - (ZixDestroyFunc)lilv_ui_free); + (LilvFreeFunc)lilv_ui_free); } LilvPluginClasses* lilv_plugin_classes_new(void) { return lilv_collection_new(lilv_header_compare_by_uri, - (ZixDestroyFunc)lilv_plugin_class_free); + (LilvFreeFunc)lilv_plugin_class_free); } /* URI based accessors (for collections of things with URIs) */ |