diff options
| author | Edward Thomson <ethomson@microsoft.com> | 2014-01-08 10:07:30 -0800 |
|---|---|---|
| committer | Edward Thomson <ethomson@microsoft.com> | 2014-01-08 10:08:23 -0800 |
| commit | 6adcaab70cdd6ced307a71945a1f80833ec9670f (patch) | |
| tree | 4d10a5a2d7aa1cc16299c1bbcb006b371f8f8129 /src/buffer.h | |
| parent | 32309b5d82d95402852cfcd478abec5d116eba86 (diff) | |
| download | libgit2-6adcaab70cdd6ced307a71945a1f80833ec9670f.tar.gz | |
Handle git_buf's from users more liberally
Diffstat (limited to 'src/buffer.h')
| -rw-r--r-- | src/buffer.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/buffer.h b/src/buffer.h index c88af6fef..564a4f561 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -51,6 +51,15 @@ extern void git_buf_init(git_buf *buf, size_t initial_size); extern int git_buf_try_grow( git_buf *buf, size_t target_size, bool mark_oom, bool preserve_external); +/** + * Sanitizes git_buf structures provided from user input. Users of the + * library, when providing git_buf's, may wish to provide a NULL ptr for + * ease of handling. The buffer routines, however, expect a non-NULL ptr + * always. This helper method simply handles NULL input, converting to a + * git_buf__initbuf. + */ +extern void git_buf_sanitize(git_buf *buf); + extern void git_buf_swap(git_buf *buf_a, git_buf *buf_b); extern char *git_buf_detach(git_buf *buf); extern void git_buf_attach(git_buf *buf, char *ptr, size_t asize); |
