diff options
author | Jacques Germishuys <jacquesg@striata.com> | 2014-04-10 12:43:16 +0200 |
---|---|---|
committer | Jacques Germishuys <jacquesg@striata.com> | 2014-04-10 18:24:16 +0200 |
commit | b3b36a68d16f1fdc383a06fbe85c3cc042d86314 (patch) | |
tree | 2d0b6f330b0231952134cefaaba2e9df0addf47d /src | |
parent | bcc622934a90307390f058c7ef4203f8bbcfe0d6 (diff) | |
download | libgit2-b3b36a68d16f1fdc383a06fbe85c3cc042d86314.tar.gz |
Introduce git_buf_putcn
Allows for inserting the same character n amount of times
Diffstat (limited to 'src')
-rw-r--r-- | src/buffer.c | 9 | ||||
-rw-r--r-- | src/buffer.h | 1 |
2 files changed, 10 insertions, 0 deletions
diff --git a/src/buffer.c b/src/buffer.c index 83960e912..f6e34a445 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -148,6 +148,15 @@ int git_buf_putc(git_buf *buf, char c) return 0; } +int git_buf_putcn(git_buf *buf, char c, size_t len) +{ + ENSURE_SIZE(buf, buf->size + len + 1); + memset(buf->ptr + buf->size, c, len); + buf->size += len; + buf->ptr[buf->size] = '\0'; + return 0; +} + int git_buf_put(git_buf *buf, const char *data, size_t len) { ENSURE_SIZE(buf, buf->size + len + 1); diff --git a/src/buffer.h b/src/buffer.h index dba594d97..398aec9b7 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -88,6 +88,7 @@ GIT_INLINE(bool) git_buf_oom(const git_buf *buf) */ int git_buf_sets(git_buf *buf, const char *string); int git_buf_putc(git_buf *buf, char c); +int git_buf_putcn(git_buf *buf, char c, size_t len); int git_buf_put(git_buf *buf, const char *data, size_t len); int git_buf_puts(git_buf *buf, const char *string); int git_buf_printf(git_buf *buf, const char *format, ...) GIT_FORMAT_PRINTF(2, 3); |