Skip to content

Commit 3c905dd

Browse files
committed
Merge branch 'jn/strbuf-doc-re-reuse' into maint
* jn/strbuf-doc-re-reuse: strbuf doc: reuse after strbuf_release is fine
2 parents 116d1d4 + e022215 commit 3c905dd

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

strbuf.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,22 @@ extern char strbuf_slopbuf[];
8282
extern void strbuf_init(struct strbuf *, size_t);
8383

8484
/**
85-
* Release a string buffer and the memory it used. You should not use the
86-
* string buffer after using this function, unless you initialize it again.
85+
* Release a string buffer and the memory it used. After this call, the
86+
* strbuf points to an empty string that does not need to be free()ed, as
87+
* if it had been set to `STRBUF_INIT` and never modified.
88+
*
89+
* To clear a strbuf in preparation for further use without the overhead
90+
* of free()ing and malloc()ing again, use strbuf_reset() instead.
8791
*/
8892
extern void strbuf_release(struct strbuf *);
8993

9094
/**
9195
* Detach the string from the strbuf and returns it; you now own the
9296
* storage the string occupies and it is your responsibility from then on
9397
* to release it with `free(3)` when you are done with it.
98+
*
99+
* The strbuf that previously held the string is reset to `STRBUF_INIT` so
100+
* it can be reused after calling this function.
94101
*/
95102
extern char *strbuf_detach(struct strbuf *, size_t *);
96103

0 commit comments

Comments
 (0)