From: Not Zed Date: Wed, 9 Jun 2021 00:07:23 +0000 (+0930) Subject: Constify read-only arguments. X-Git-Url: https://code.zedzone.au/cvs?a=commitdiff_plain;h=afb3d0d091819a02efddfee62b664c0d483c32e3;p=libeze Constify read-only arguments. --- diff --git a/ez-node.h b/ez-node.h index 74f12bb..7e3a7d5 100644 --- a/ez-node.h +++ b/ez-node.h @@ -139,12 +139,11 @@ struct ez_string_node { #include // see also ez-set.h ez_string_node_hash() - -static __inline__ int ez_string_node_equals(void *a, void *b) { +static __inline__ int ez_string_node_equals(const void *a, const void *b) { return strcmp(((struct ez_string_node *)a)->name, ((struct ez_string_node *)b)->name) == 0; } -static __inline__ int ez_string_node_cmp(void *a, void *b) { +static __inline__ int ez_string_node_cmp(const void *a, const void *b) { return strcmp(((struct ez_string_node *)a)->name, ((struct ez_string_node *)b)->name); } diff --git a/ez-tree.c b/ez-tree.c index ee6d390..5ebb2af 100644 --- a/ez-tree.c +++ b/ez-tree.c @@ -403,7 +403,7 @@ static void *ez_tree_scan_dir(ez_tree_scan *scan, enum ez_node_link_t dir) { } } -void *ez_tree_scan_init_key(ez_tree *tree, ez_tree_scan *scan, enum ez_node_link_t scan_dir, enum ez_node_link_t key_dir, void *key) { +void *ez_tree_scan_init_key(ez_tree *tree, ez_tree_scan *scan, enum ez_node_link_t scan_dir, enum ez_node_link_t key_dir, const void *key) { struct ez_node *p = ez_node_right(&tree->root); ez_cmp_fn node_cmp = tree->node_cmp; int l = 0; diff --git a/ez-tree.h b/ez-tree.h index 6ecb3ce..83c9b7a 100644 --- a/ez-tree.h +++ b/ez-tree.h @@ -172,8 +172,7 @@ void *ez_tree_remove(ez_tree *tree, const void *key_node); * @param key_node optional key node for starting point. * @return The found node if any is returned. */ -void *ez_tree_scan_init_key(ez_tree *tree, ez_tree_scan *scan, enum ez_node_link_t scan_dir, enum ez_node_link_t key_dir, void *key_node); - +void *ez_tree_scan_init_key(ez_tree *tree, ez_tree_scan *scan, enum ez_node_link_t scan_dir, enum ez_node_link_t key_dir, const void *key_node); /** * Initialise tree scanner for walking tree in order from an end.