buf: add consume_bytes Allow users to consume a buffer by the number of bytes, not just to an ending pointer.
diff --git a/src/buffer.c b/src/buffer.c
index 61cf967..328fdfe 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -567,6 +567,11 @@ void git_buf_copy_cstr(char *data, size_t datasize, const git_buf *buf)
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)
{
if (end > buf->ptr && end <= buf->ptr + buf->size) {
diff --git a/src/buffer.h b/src/buffer.h
index 7910b63..6b717d2 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -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_vprintf(git_buf *buf, const char *format, va_list ap);
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_truncate(git_buf *buf, size_t len);
void git_buf_shorten(git_buf *buf, size_t amount);