Commit b3b36a68 by Jacques Germishuys

Introduce git_buf_putcn

Allows for inserting the same character n amount of times
parent bcc62293
...@@ -148,6 +148,15 @@ int git_buf_putc(git_buf *buf, char c) ...@@ -148,6 +148,15 @@ int git_buf_putc(git_buf *buf, char c)
return 0; 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) int git_buf_put(git_buf *buf, const char *data, size_t len)
{ {
ENSURE_SIZE(buf, buf->size + len + 1); ENSURE_SIZE(buf, buf->size + len + 1);
......
...@@ -88,6 +88,7 @@ GIT_INLINE(bool) git_buf_oom(const git_buf *buf) ...@@ -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_sets(git_buf *buf, const char *string);
int git_buf_putc(git_buf *buf, char c); 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_put(git_buf *buf, const char *data, size_t len);
int git_buf_puts(git_buf *buf, const char *string); 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); int git_buf_printf(git_buf *buf, const char *format, ...) GIT_FORMAT_PRINTF(2, 3);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment