summaryrefslogtreecommitdiff
path: root/src/hashtable.c
diff options
context:
space:
mode:
authorCarlos Martín Nieto <carlos@cmartin.tk>2012-01-19 19:06:15 +0100
committerCarlos Martín Nieto <carlos@cmartin.tk>2012-01-19 19:06:15 +0100
commit3f2bf4d659b33db9363d44f14d46154674d4049c (patch)
tree88313142f9ff2d17774a8a870294468c58593a5c /src/hashtable.c
parentd0ec3fb8f07988779783f69ab6cf5f3431c7aa3e (diff)
downloadlibgit2-3f2bf4d659b33db9363d44f14d46154674d4049c.tar.gz
hashtable: add remove2 to retrieve the value that was removed
Diffstat (limited to 'src/hashtable.c')
-rw-r--r--src/hashtable.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/hashtable.c b/src/hashtable.c
index f836f166d..89c44ba9e 100644
--- a/src/hashtable.c
+++ b/src/hashtable.c
@@ -213,7 +213,7 @@ void *git_hashtable_lookup(git_hashtable *self, const void *key)
return NULL;
}
-int git_hashtable_remove(git_hashtable *self, const void *key)
+int git_hashtable_remove2(git_hashtable *self, const void *key, void **old_value)
{
int hash_id;
git_hashtable_node *node;
@@ -223,6 +223,7 @@ int git_hashtable_remove(git_hashtable *self, const void *key)
for (hash_id = 0; hash_id < GIT_HASHTABLE_HASHES; ++hash_id) {
node = node_with_hash(self, key, hash_id);
if (node->key && self->key_equal(key, node->key) == 0) {
+ *old_value = node->value;
node->key = NULL;
node->value = NULL;
self->key_count--;