diff options
Diffstat (limited to 'lib/gnutls_mbuffers.h')
-rw-r--r-- | lib/gnutls_mbuffers.h | 59 |
1 files changed, 35 insertions, 24 deletions
diff --git a/lib/gnutls_mbuffers.h b/lib/gnutls_mbuffers.h index beb1eabdec..9eaf310f6a 100644 --- a/lib/gnutls_mbuffers.h +++ b/lib/gnutls_mbuffers.h @@ -23,75 +23,85 @@ */ #ifndef GNUTLS_MBUFFERS_H -# define GNUTLS_MBUFFERS_H +#define GNUTLS_MBUFFERS_H #include <gnutls_int.h> #include <gnutls_errors.h> -void _mbuffer_init (mbuffer_head_st *buf); -void _mbuffer_clear (mbuffer_head_st *buf); -void _mbuffer_enqueue (mbuffer_head_st *buf, mbuffer_st *bufel); -int _mbuffer_remove_bytes (mbuffer_head_st *buf, size_t bytes); -mbuffer_st* _mbuffer_alloc (size_t payload_size, size_t maximum_size); +void _mbuffer_init (mbuffer_head_st * buf); +void _mbuffer_clear (mbuffer_head_st * buf); +void _mbuffer_enqueue (mbuffer_head_st * buf, mbuffer_st * bufel); +int _mbuffer_remove_bytes (mbuffer_head_st * buf, size_t bytes); +mbuffer_st *_mbuffer_alloc (size_t payload_size, size_t maximum_size); -mbuffer_st* _mbuffer_get_first (mbuffer_head_st *buf, gnutls_datum_t *msg); -mbuffer_st* _mbuffer_get_next (mbuffer_st * cur, gnutls_datum_t *msg); +mbuffer_st *_mbuffer_get_first (mbuffer_head_st * buf, gnutls_datum_t * msg); +mbuffer_st *_mbuffer_get_next (mbuffer_st * cur, gnutls_datum_t * msg); /* This is dangerous since it will replace bufel with a new * one. */ -int _mbuffer_append_data (mbuffer_st *bufel, void* newdata, size_t newdata_size); -int _mbuffer_linearize (mbuffer_head_st *buf); +int _mbuffer_append_data (mbuffer_st * bufel, void *newdata, + size_t newdata_size); +int _mbuffer_linearize (mbuffer_head_st * buf); /* For "user" use. One can have buffer data and header. */ -inline static void _mbuffer_set_udata(mbuffer_st *bufel, void* data, size_t data_size) +inline static void +_mbuffer_set_udata (mbuffer_st * bufel, void *data, size_t data_size) { - memcpy(bufel->msg.data + bufel->user_mark, data, data_size); + memcpy (bufel->msg.data + bufel->user_mark, data, data_size); } -inline static void* _mbuffer_get_uhead_ptr(mbuffer_st *bufel) +inline static void * +_mbuffer_get_uhead_ptr (mbuffer_st * bufel) { return bufel->msg.data; } -inline static void* _mbuffer_get_udata_ptr(mbuffer_st *bufel) +inline static void * +_mbuffer_get_udata_ptr (mbuffer_st * bufel) { return bufel->msg.data + bufel->user_mark; } -inline static void _mbuffer_set_udata_size(mbuffer_st *bufel, size_t size) +inline static void +_mbuffer_set_udata_size (mbuffer_st * bufel, size_t size) { bufel->msg.size = size + bufel->user_mark; } -inline static size_t _mbuffer_get_udata_size(mbuffer_st *bufel) +inline static size_t +_mbuffer_get_udata_size (mbuffer_st * bufel) { return bufel->msg.size - bufel->user_mark; } -inline static size_t _mbuffer_get_uhead_size(mbuffer_st *bufel) +inline static size_t +_mbuffer_get_uhead_size (mbuffer_st * bufel) { return bufel->user_mark; } -inline static void _mbuffer_set_uhead_size(mbuffer_st *bufel, size_t size) +inline static void +_mbuffer_set_uhead_size (mbuffer_st * bufel, size_t size) { bufel->user_mark = size; } -inline static mbuffer_st* _gnutls_handshake_alloc(size_t size, size_t maximum) +inline static mbuffer_st * +_gnutls_handshake_alloc (size_t size, size_t maximum) { - mbuffer_st *ret = _mbuffer_alloc (HANDSHAKE_HEADER_SIZE + size, HANDSHAKE_HEADER_SIZE+maximum); + mbuffer_st *ret = _mbuffer_alloc (HANDSHAKE_HEADER_SIZE + size, + HANDSHAKE_HEADER_SIZE + maximum); if (!ret) return NULL; - _mbuffer_set_uhead_size(ret, HANDSHAKE_HEADER_SIZE); + _mbuffer_set_uhead_size (ret, HANDSHAKE_HEADER_SIZE); return ret; } @@ -102,10 +112,11 @@ inline static mbuffer_st* _gnutls_handshake_alloc(size_t size, size_t maximum) * pointer case). It also makes sure the pointer has a known value * after freeing. */ -inline static void _mbuffer_xfree(mbuffer_st **bufel) +inline static void +_mbuffer_xfree (mbuffer_st ** bufel) { - if(*bufel) - gnutls_free(*bufel); + if (*bufel) + gnutls_free (*bufel); *bufel = NULL; } |