Skip to content

Commit d68f2b1

Browse files
committed
buf: add consume_bytes
Allow users to consume a buffer by the number of bytes, not just to an ending pointer.
1 parent e995f74 commit d68f2b1

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/buffer.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,11 @@ void git_buf_copy_cstr(char *data, size_t datasize, const git_buf *buf)
567567
data[copylen] = '\0';
568568
}
569569

570+
void git_buf_consume_bytes(git_buf *buf, size_t len)
571+
{
572+
git_buf_consume(buf, buf->ptr + len);
573+
}
574+
570575
void git_buf_consume(git_buf *buf, const char *end)
571576
{
572577
if (end > buf->ptr && end <= buf->ptr + buf->size) {

src/buffer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ int git_buf_puts(git_buf *buf, const char *string);
113113
int git_buf_printf(git_buf *buf, const char *format, ...) GIT_FORMAT_PRINTF(2, 3);
114114
int git_buf_vprintf(git_buf *buf, const char *format, va_list ap);
115115
void git_buf_clear(git_buf *buf);
116+
void git_buf_consume_bytes(git_buf *buf, size_t len);
116117
void git_buf_consume(git_buf *buf, const char *end);
117118
void git_buf_truncate(git_buf *buf, size_t len);
118119
void git_buf_shorten(git_buf *buf, size_t amount);

0 commit comments

Comments
 (0)