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

Merge branch 'master-stable'

parents a9a8f931 a9890515
No related branches found
No related tags found
No related merge requests found
......@@ -1452,8 +1452,7 @@ case 107:
#line 199 "core/admin.rl"
fiber->rbuf->len -= (void *)pe - (void *)fiber->rbuf->data;
fiber->rbuf->data = pe;
tbuf_ltrim(fiber->rbuf, (void *)pe - (void *)fiber->rbuf->data);
if (p != pe) {
start(out);
......
......@@ -198,8 +198,7 @@ admin_dispatch(void)
write exec;
}%%
fiber->rbuf->len -= (void *)pe - (void *)fiber->rbuf->data;
fiber->rbuf->data = pe;
tbuf_ltrim(fiber->rbuf, (void *)pe - (void *)fiber->rbuf->data);
if (p != pe) {
start(out);
......
......@@ -125,6 +125,18 @@ tbuf_peek(struct tbuf *b, size_t count)
return NULL;
}
/** Remove first count bytes from the beginning. */
void
tbuf_ltrim(struct tbuf *b, size_t count)
{
tbuf_assert(b);
assert(count <= b->len);
memmove(b->data, b->data + count, b->len - count);
b->len -= count;
}
size_t
tbuf_reserve(struct tbuf *b, size_t count)
{
......
......@@ -63,6 +63,16 @@ size_t tbuf_reserve(struct tbuf *b, size_t count);
void tbuf_reset(struct tbuf *b);
void *tbuf_peek(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_vprintf(struct tbuf *b, const char *format, va_list ap)
__attribute__ ((format(FORMAT_PRINTF, 2, 0)));
......
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