This is similar to _mbuffer_enqueue, but adds an element to the
beginning of the buffer.
This is to make the incomplete header handling case easier.
Signed-off-by: Daiki Ueno <dueno@redhat.com>
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.
*
gnutls_datum_t * msg);
mbuffer_st *_mbuffer_head_get_next(mbuffer_st * cur, gnutls_datum_t * msg);
+void _mbuffer_head_push_first(mbuffer_head_st * buf, mbuffer_st * bufel);
+
mbuffer_st *_mbuffer_head_pop_first(mbuffer_head_st * buf);
/* This is dangerous since it will replace bufel with a new