summaryrefslogtreecommitdiff
path: root/include/git2
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2018-01-12 13:03:19 +0000
committerPatrick Steinhardt <ps@pks.im>2018-01-12 13:13:57 +0000
commit5963292f9ebc8b06ad307e2ed10eec845424e74e (patch)
tree191eaceed5badd295247faf03290ccbfbeb4a9ca /include/git2
parent90f81f9fdc6d87c4ca75e4f065e1eb4818c99674 (diff)
downloadlibgit2-5963292f9ebc8b06ad307e2ed10eec845424e74e.tar.gz
refs: document need to free refs in foreach-callback
References passed to the callback function of `git_reference_foreach` are expected to be owned by the callback. As such, they are never being freed by `git_reference_foreach`, but will have to be freed by the caller. This small detail is never mentioned in the function's documentation, though, making it easy to get wrong. Document this to make it discoverable.
Diffstat (limited to 'include/git2')
-rw-r--r--include/git2/refs.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/include/git2/refs.h b/include/git2/refs.h
index dee28cb5b..0dd453e55 100644
--- a/include/git2/refs.h
+++ b/include/git2/refs.h
@@ -433,6 +433,9 @@ typedef int (*git_reference_foreach_name_cb)(const char *name, void *payload);
* passed to this method. Returning a non-zero value from the callback
* will terminate the iteration.
*
+ * Note that the callback function is responsible to call `git_reference_free`
+ * on each reference passed to it.
+ *
* @param repo Repository where to find the refs
* @param callback Function which will be called for every listed ref
* @param payload Additional data to pass to the callback