Skip to content
Snippets Groups Projects
Commit a9890515 authored by Konstantin Osipov's avatar Konstantin Osipov
Browse files

Bug#773058: review fixes.

Adjust signature of tbuf_ltrim, add comments,
replace a check with an assert.
parent e4d88801
No related branches found
No related tags found
No related merge requests found
...@@ -124,17 +124,16 @@ tbuf_peek(struct tbuf *b, size_t count) ...@@ -124,17 +124,16 @@ tbuf_peek(struct tbuf *b, size_t count)
return NULL; return NULL;
} }
void * /** Remove first count bytes from the beginning. */
void
tbuf_ltrim(struct tbuf *b, size_t count) tbuf_ltrim(struct tbuf *b, size_t count)
{ {
void *p = NULL;
tbuf_assert(b); tbuf_assert(b);
if (count <= b->len) { assert(count <= b->len);
p = memmove(b->data, b->data + count, b->len - count);
b->len -= count; memmove(b->data, b->data + count, b->len - count);
} b->len -= count;
return p;
} }
size_t size_t
......
...@@ -63,7 +63,16 @@ struct tbuf *tbuf_split(struct tbuf *e, size_t at); ...@@ -63,7 +63,16 @@ struct tbuf *tbuf_split(struct tbuf *e, size_t at);
size_t tbuf_reserve(struct tbuf *b, size_t count); size_t tbuf_reserve(struct tbuf *b, size_t count);
void tbuf_reset(struct tbuf *b); void tbuf_reset(struct tbuf *b);
void *tbuf_peek(struct tbuf *b, size_t count); void *tbuf_peek(struct tbuf *b, size_t count);
void *tbuf_ltrim(struct tbuf *b, size_t count);
/**
* Remove count bytes from the beginning, and adjust all sizes
* accordingly.
*
* @param count the number of bytes to forget about.
*
* @pre 0 <= count <= tbuf->len
*/
void tbuf_ltrim(struct tbuf *b, size_t count);
void tbuf_append_field(struct tbuf *b, void *f); void tbuf_append_field(struct tbuf *b, void *f);
void tbuf_vprintf(struct tbuf *b, const char *format, va_list ap) void tbuf_vprintf(struct tbuf *b, const char *format, va_list ap)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment