summaryrefslogtreecommitdiff
path: root/src/oidmap.h
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2018-12-01 08:50:36 +0100
committerPatrick Steinhardt <ps@pks.im>2019-02-15 13:16:48 +0100
commit84a089da3701db370b2c77e6866abe3a5065c542 (patch)
treea70b47efb1c29ab0c779fbb7f25447a33d9d0dce /src/oidmap.h
parent8da93944f3d3c271ea7a2ec035c6ea48654fa71e (diff)
downloadlibgit2-84a089da3701db370b2c77e6866abe3a5065c542.tar.gz
maps: provide return value when deleting entries
Currently, the delete functions of maps do not provide a return value. Like this, it is impossible to tell whether the entry has really been deleted or not. Change the implementation to provide either a return value of zero if the entry has been successfully deleted or `GIT_ENOTFOUND` if the key could not be found. Convert callers to the `delete_at` functions to instead use this higher-level interface.
Diffstat (limited to 'src/oidmap.h')
-rw-r--r--src/oidmap.h15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/oidmap.h b/src/oidmap.h
index 39987d336..d8ffb92ac 100644
--- a/src/oidmap.h
+++ b/src/oidmap.h
@@ -76,6 +76,20 @@ void *git_oidmap_get(git_oidmap *map, const git_oid *key);
*/
int git_oidmap_set(git_oidmap *map, const git_oid *key, void *value);
+/**
+ * Delete an entry from the map.
+ *
+ * Delete the given key and its value from the map. If no such
+ * key exists, this will do nothing.
+ *
+ * @param map map to delete key in
+ * @param key key to delete
+ * @return `0` if the key has been deleted, GIT_ENOTFOUND if no
+ * such key was found, a negative code in case of an
+ * error
+ */
+int git_oidmap_delete(git_oidmap *map, const git_oid *key);
+
size_t git_oidmap_lookup_index(git_oidmap *map, const git_oid *key);
int git_oidmap_valid_index(git_oidmap *map, size_t idx);
@@ -90,7 +104,6 @@ void git_oidmap_delete_at(git_oidmap *map, size_t idx);
int git_oidmap_put(git_oidmap *map, const git_oid *key, int *err);
void git_oidmap_insert(git_oidmap *map, const git_oid *key, void *value, int *rval);
-void git_oidmap_delete(git_oidmap *map, const git_oid *key);
size_t git_oidmap_begin(git_oidmap *map);
size_t git_oidmap_end(git_oidmap *map);