summaryrefslogtreecommitdiff
path: root/lib/mbuffers.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/mbuffers.c')
-rw-r--r--lib/mbuffers.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/mbuffers.c b/lib/mbuffers.c
index 2bcd57e426..2e4c62a295 100644
--- a/lib/mbuffers.c
+++ b/lib/mbuffers.c
@@ -126,6 +126,25 @@ mbuffer_st *_mbuffer_dequeue(mbuffer_head_st * buf, mbuffer_st * bufel)
return ret;
}
+/* Append a segment to the beginning of this buffer.
+ *
+ * Cost: O(1)
+ */
+void _mbuffer_head_push_first(mbuffer_head_st * buf, mbuffer_st * bufel)
+{
+ bufel->prev = NULL;
+ bufel->next = buf->head;
+
+ buf->length++;
+ buf->byte_length += bufel->msg.size - bufel->mark;
+
+ if (buf->head != NULL)
+ buf->head->prev = bufel;
+ else
+ buf->tail = bufel;
+ buf->head = bufel;
+}
+
/* Get a reference to the first segment of the buffer and
* remove it from the list.
*