summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-10-18 14:19:13 +0900
committerJunio C Hamano <gitster@pobox.com>2017-10-18 14:19:13 +0900
commit3c905ddd18db8b4bfe53c0067204addb3035e465 (patch)
tree58791a88729aaea1574e0e9c6965e4df2057aa78
parent116d1d4c8ec443261566773625d0304912385824 (diff)
parente0222159fa53ea24785cfb1dc5de0214e89b0117 (diff)
downloadgit-3c905ddd18db8b4bfe53c0067204addb3035e465.tar.gz
Merge branch 'jn/strbuf-doc-re-reuse' into maint
* jn/strbuf-doc-re-reuse: strbuf doc: reuse after strbuf_release is fine
-rw-r--r--strbuf.h11
1 files changed, 9 insertions, 2 deletions
diff --git a/strbuf.h b/strbuf.h
index 2075384e0b..80112a8c26 100644
--- a/strbuf.h
+++ b/strbuf.h
@@ -82,8 +82,12 @@ extern char strbuf_slopbuf[];
extern void strbuf_init(struct strbuf *, size_t);
/**
- * Release a string buffer and the memory it used. You should not use the
- * string buffer after using this function, unless you initialize it again.
+ * Release a string buffer and the memory it used. After this call, the
+ * strbuf points to an empty string that does not need to be free()ed, as
+ * if it had been set to `STRBUF_INIT` and never modified.
+ *
+ * To clear a strbuf in preparation for further use without the overhead
+ * of free()ing and malloc()ing again, use strbuf_reset() instead.
*/
extern void strbuf_release(struct strbuf *);
@@ -91,6 +95,9 @@ extern void strbuf_release(struct strbuf *);
* Detach the string from the strbuf and returns it; you now own the
* storage the string occupies and it is your responsibility from then on
* to release it with `free(3)` when you are done with it.
+ *
+ * The strbuf that previously held the string is reset to `STRBUF_INIT` so
+ * it can be reused after calling this function.
*/
extern char *strbuf_detach(struct strbuf *, size_t *);