diff options
author | Vicent Martà <tanoku@gmail.com> | 2011-11-30 11:02:34 -0800 |
---|---|---|
committer | Vicent Martà <tanoku@gmail.com> | 2011-11-30 11:02:34 -0800 |
commit | f5f048265800659aa6f495c05eb99e1b76a713e2 (patch) | |
tree | 63fb56773ea31214c1107dfa33dbecceec2b4c1c /src/buffer.h | |
parent | fc88a8d321541165b52d2cdb27753bab76870321 (diff) | |
parent | 309113c984c1f3157659dc1174e5d4218f610ae4 (diff) | |
download | libgit2-f5f048265800659aa6f495c05eb99e1b76a713e2.tar.gz |
Merge pull request #503 from arrbee/git-buf-always-cstr
Make git_buf functions always maintain a valid cstr
Diffstat (limited to 'src/buffer.h')
-rw-r--r-- | src/buffer.h | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/buffer.h b/src/buffer.h index 2ed9047ca..fa0c7f0b8 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -14,8 +14,11 @@ typedef struct { ssize_t asize, size; } git_buf; -#define GIT_BUF_INIT {NULL, 0, 0} +extern char git_buf_initbuf[]; +#define GIT_BUF_INIT { git_buf_initbuf, 0, 0 } + +void git_buf_init(git_buf *buf, size_t initial_size); int git_buf_grow(git_buf *buf, size_t target_size); void git_buf_free(git_buf *buf); void git_buf_swap(git_buf *buf_a, git_buf *buf_b); @@ -42,6 +45,7 @@ void git_buf_join(git_buf *buf, char separator, const char *str_a, const char *s const char *git_buf_cstr(git_buf *buf); char *git_buf_take_cstr(git_buf *buf); +void git_buf_copy_cstr(char *data, size_t datasize, git_buf *buf); #define git_buf_PUTS(buf, str) git_buf_put(buf, str, sizeof(str) - 1) |