diff options
author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2011-02-26 11:27:13 +0100 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2011-03-02 18:45:59 +0100 |
commit | 5d1ef73207befe4d46e6666dda5a698faa7f7ab9 (patch) | |
tree | 61bcb1e6c082aaea786ae6512c43627ce4197e8f /lib/gnutls_mbuffers.c | |
parent | 601b2229fb79467961e713ea636ce0c6fedd3c73 (diff) | |
download | gnutls-5d1ef73207befe4d46e6666dda5a698faa7f7ab9.tar.gz |
internal buffering for record and handshake data changed from gnutls_buffers to gnutls_mbuffers.
Diffstat (limited to 'lib/gnutls_mbuffers.c')
-rw-r--r-- | lib/gnutls_mbuffers.c | 44 |
1 files changed, 35 insertions, 9 deletions
diff --git a/lib/gnutls_mbuffers.c b/lib/gnutls_mbuffers.c index e58a3c3165..297c9b286f 100644 --- a/lib/gnutls_mbuffers.c +++ b/lib/gnutls_mbuffers.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 Free Software Foundation + * Copyright (C) 2009,2011 Free Software Foundation * * Author: Jonathan Bastien-Filiatrault * @@ -98,6 +98,29 @@ _mbuffer_enqueue (mbuffer_head_st * buf, mbuffer_st * bufel) buf->tail = &bufel->next; } +/* Get a reference to the first segment of the buffer and + * remove it from the list. + * + * Used to start iteration. + * + * Cost: O(1) + */ +mbuffer_st * +_mbuffer_pop_first (mbuffer_head_st * buf) +{ + mbuffer_st *bufel = buf->head; + + buf->head = bufel->next; + + buf->byte_length -= (bufel->msg.size - bufel->mark); + buf->length -= 1; + + if (!buf->head) + buf->tail = &buf->head; + + return bufel; +} + /* Get a reference to the first segment of the buffer and its data. * * Used to start iteration or to peek at the data. @@ -109,15 +132,18 @@ _mbuffer_get_first (mbuffer_head_st * buf, gnutls_datum_t * msg) { mbuffer_st *bufel = buf->head; - if (bufel) + if (msg) { - msg->data = bufel->msg.data + bufel->mark; - msg->size = bufel->msg.size - bufel->mark; - } - else - { - msg->data = NULL; - msg->size = 0; + if (bufel) + { + msg->data = bufel->msg.data + bufel->mark; + msg->size = bufel->msg.size - bufel->mark; + } + else + { + msg->data = NULL; + msg->size = 0; + } } return bufel; } |