diff options
author | Simo Sorce <ssorce@redhat.com> | 2009-03-02 13:54:05 -0500 |
---|---|---|
committer | Simo Sorce <ssorce@redhat.com> | 2009-03-02 16:03:41 -0500 |
commit | ada6a885cf8a49704f13de2a8fc289aa1455cd4c (patch) | |
tree | 6908dda8508af7e44f25c2f502fba63fd9bbf576 /server/util | |
parent | 422e3a220e219a771efc9c3597c6b16724f55c47 (diff) | |
download | sssd-ada6a885cf8a49704f13de2a8fc289aa1455cd4c.tar.gz sssd-ada6a885cf8a49704f13de2a8fc289aa1455cd4c.tar.xz sssd-ada6a885cf8a49704f13de2a8fc289aa1455cd4c.zip |
Do not steal memory in btreemaps.
Just make sure that the memory passed in is either static or allocated on the
same memory context that is parent of the btreemap.
Diffstat (limited to 'server/util')
-rw-r--r-- | server/util/btreemap.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/server/util/btreemap.c b/server/util/btreemap.c index 9bfc98550..43646c34c 100644 --- a/server/util/btreemap.c +++ b/server/util/btreemap.c @@ -51,7 +51,8 @@ struct btreemap * BTREEMAP_CREATE_LEFT: A new node created should use node->left * BTREEMAP_CREATE_RIGHT: A new node created should use node->right */ -int btreemap_search_key(struct btreemap *map, const void *key, struct btreemap **node) +int btreemap_search_key(struct btreemap *map, + const void *key, struct btreemap **node) { struct btreemap *tempnode; int result; @@ -147,8 +148,8 @@ int btreemap_set_value(TALLOC_CTX *mem_ctx, { return ENOMEM; } - new_node->key = talloc_steal(new_node, key); - new_node->value = talloc_steal(new_node, value); + new_node->key = key; + new_node->value = value; new_node->comparator = comparator; new_node->left = NULL; new_node->right = NULL; @@ -205,7 +206,9 @@ static int _btreemap_get_keys(TALLOC_CTX *mem_ctx, struct btreemap *map, } /* Return an array of keys in sort order */ -int btreemap_get_keys(TALLOC_CTX *mem_ctx, struct btreemap *map, const void ***array, int *count) +int btreemap_get_keys(TALLOC_CTX *mem_ctx, + struct btreemap *map, + const void ***array, int *count) { *array = NULL; *count = 0; |