From d09f8a08bdd9477bd463a2de03397ff56b5ce75d Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Wed, 13 Jul 2016 23:11:55 +0200 Subject: Add delta wrt. function in stack dump --- src/common/include/btree.h | 4 ++-- src/common/libalgo/btree.c | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'src/common') diff --git a/src/common/include/btree.h b/src/common/include/btree.h index 9975885..a645d66 100644 --- a/src/common/include/btree.h +++ b/src/common/include/btree.h @@ -23,8 +23,8 @@ void btree_remove(btree_t *t, const void* key); void btree_remove_v(btree_t *t, const void* key, const void* value); void* btree_find(btree_t *i, const void* key); -void* btree_lower(btree_t *i, const void* key); -void* btree_upper(btree_t *i, const void* key); +void* btree_lower(btree_t *i, const void* key, void** actual_key); +void* btree_upper(btree_t *i, const void* key, void** actual_key); void btree_iter(btree_t *i, kv_iter_fun_t f); void btree_iter_on(btree_t *i, const void* key, kv_iter_fun_t f); diff --git a/src/common/libalgo/btree.c b/src/common/libalgo/btree.c index 6bc0fdc..45fde1e 100644 --- a/src/common/libalgo/btree.c +++ b/src/common/libalgo/btree.c @@ -272,7 +272,7 @@ void* btree_find(btree_t *t, const void* key) { return i->val; } -void* btree_lower(btree_t *t, const void* key) { +void* btree_lower(btree_t *t, const void* key, void** actual_key) { btree_item_t *find_aux(btree_t *t, btree_item_t *i, const void* key) { if (i == 0) return 0; @@ -291,10 +291,11 @@ void* btree_lower(btree_t *t, const void* key) { btree_item_t *i = find_aux(t, t->root, key); if (i == 0) return 0; + if (actual_key != 0) *actual_key = i->key; return i->val; } -void* btree_upper(btree_t *t, const void* key) { +void* btree_upper(btree_t *t, const void* key, void** actual_key) { btree_item_t *find_aux(btree_t *t, btree_item_t *i, const void* key) { if (i == 0) return 0; @@ -313,6 +314,7 @@ void* btree_upper(btree_t *t, const void* key) { btree_item_t *i = find_aux(t, t->root, key); if (i == 0) return 0; + if (actual_key != 0) *actual_key = i->key; return i->val; } -- cgit v1.2.3