Commit d68f2b1a by Edward Thomson

buf: add consume_bytes

Allow users to consume a buffer by the number of bytes, not just to an
ending pointer.
parent e995f74e
...@@ -567,6 +567,11 @@ void git_buf_copy_cstr(char *data, size_t datasize, const git_buf *buf) ...@@ -567,6 +567,11 @@ void git_buf_copy_cstr(char *data, size_t datasize, const git_buf *buf)
data[copylen] = '\0'; data[copylen] = '\0';
} }
void git_buf_consume_bytes(git_buf *buf, size_t len)
{
git_buf_consume(buf, buf->ptr + len);
}
void git_buf_consume(git_buf *buf, const char *end) void git_buf_consume(git_buf *buf, const char *end)
{ {
if (end > buf->ptr && end <= buf->ptr + buf->size) { if (end > buf->ptr && end <= buf->ptr + buf->size) {
......
...@@ -113,6 +113,7 @@ int git_buf_puts(git_buf *buf, const char *string); ...@@ -113,6 +113,7 @@ 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);
int git_buf_vprintf(git_buf *buf, const char *format, va_list ap); int git_buf_vprintf(git_buf *buf, const char *format, va_list ap);
void git_buf_clear(git_buf *buf); void git_buf_clear(git_buf *buf);
void git_buf_consume_bytes(git_buf *buf, size_t len);
void git_buf_consume(git_buf *buf, const char *end); void git_buf_consume(git_buf *buf, const char *end);
void git_buf_truncate(git_buf *buf, size_t len); void git_buf_truncate(git_buf *buf, size_t len);
void git_buf_shorten(git_buf *buf, size_t amount); void git_buf_shorten(git_buf *buf, size_t amount);
......
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