Skip to content

Commit cdb2c2a

Browse files
committed
buffer: clarify how git_buf_sanitize handles non-NULL input
When `git_buf_sanitize` gets called, it converts a buffer with NULL content to be correctly initialized. This is done by pointing it to `git_buf__initbuf`. While the method's documentation states this clearly, it may also lead to the conclusion that it will do the same to buffers which do _not_ have NULL contents. Clarify behavior when passing a buffer with non-NULL contents, where `git_buf_sanitize` will ensure that the contents are `\0`-terminated.
1 parent 4f9f8e0 commit cdb2c2a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/buffer.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ extern int git_buf_try_grow(
6666
* library, when providing git_buf's, may wish to provide a NULL ptr for
6767
* ease of handling. The buffer routines, however, expect a non-NULL ptr
6868
* always. This helper method simply handles NULL input, converting to a
69-
* git_buf__initbuf.
69+
* git_buf__initbuf. If a buffer with a non-NULL ptr is passed in, this method
70+
* assures that the buffer is '\0'-terminated.
7071
*/
7172
extern void git_buf_sanitize(git_buf *buf);
7273

0 commit comments

Comments
 (0)