1
0
mirror of https://github.com/moparisthebest/spdylay synced 2024-11-05 17:15:05 -05:00

Exposed spdylay_frame_alloc_{pack,unpack}_nv for easy performance test

This commit is contained in:
Tatsuhiro Tsujikawa 2012-03-01 23:52:15 +09:00
parent aded9420af
commit e29bb449e9
2 changed files with 62 additions and 46 deletions

View File

@ -85,28 +85,13 @@ static void spdylay_frame_unpack_ctrl_hd(spdylay_ctrl_hd *hd,
hd->length = spdylay_get_uint32(&buf[4]) & SPDYLAY_LENGTH_MASK;
}
/*
* Packs name/value pairs in |nv| in |*buf_ptr| with offset
* |nv_offset|. It means first byte of packed name/value pairs is
* stored in |*buf_ptr|+|nv_offset|. |*buf_ptr| and |*nvbuf_ptr| are
* expanded as necessary.
*
* This function returns the number of the bytes for the frame
* containing this name/value pairs if it succeeds, or one of the
* following negative error codes:
*
* SPDYLAY_ERR_ZLIB
* The deflate operation failed.
* SPDYLAY_ERR_NOMEM
* Out of memory.
*/
static ssize_t spdylay_frame_alloc_pack_nv(uint8_t **buf_ptr,
size_t *buflen_ptr,
uint8_t **nvbuf_ptr,
size_t *nvbuflen_ptr,
char **nv, size_t nv_offset,
size_t len_size,
spdylay_zlib *deflater)
ssize_t spdylay_frame_alloc_pack_nv(uint8_t **buf_ptr,
size_t *buflen_ptr,
uint8_t **nvbuf_ptr,
size_t *nvbuflen_ptr,
char **nv, size_t nv_offset,
size_t len_size,
spdylay_zlib *deflater)
{
size_t nvspace;
size_t maxframelen;
@ -237,30 +222,13 @@ int spdylay_frame_unpack_nv(char ***nv_ptr, const uint8_t *in, size_t inlen,
return 0;
}
/*
* Unpacks name/value pairs from buffer |in| with length |inlen|. The
* necessary memory area required for output is allocated and its
* pointer is assigned to |nv_ptr|. |inflatebuf| is used for inflate
* operation. |*nvbuf_ptr| is used for temporarily stored inflated
* name/value pair in wire format. It is expanded as necessary.
* |len_size| is the number of bytes used in name/value length. It
* must be either 2 or 4.
*
* This function returns 0 if it succeeds, or one of the following
* negative error codes:
*
* SPDYLAY_ERR_ZLIB
* The inflate operation failed.
* SPDYLAY_ERR_NOMEM
* Out of memory.
*/
static int spdylay_frame_alloc_unpack_nv(char ***nv_ptr,
spdylay_buffer *inflatebuf,
uint8_t **nvbuf_ptr,
size_t *nvbuflen_ptr,
const uint8_t *in, size_t inlen,
size_t len_size,
spdylay_zlib *inflater)
int spdylay_frame_alloc_unpack_nv(char ***nv_ptr,
spdylay_buffer *inflatebuf,
uint8_t **nvbuf_ptr,
size_t *nvbuflen_ptr,
const uint8_t *in, size_t inlen,
size_t len_size,
spdylay_zlib *inflater)
{
ssize_t nvspace;
int r;

View File

@ -392,6 +392,29 @@ size_t spdylay_frame_count_nv_space(char **nv, size_t len_size);
*/
ssize_t spdylay_frame_pack_nv(uint8_t *buf, char **nv, size_t len_size);
/*
* Packs name/value pairs in |nv| in |*buf_ptr| with offset
* |nv_offset|. It means first byte of packed name/value pairs is
* stored in |*buf_ptr|+|nv_offset|. |*buf_ptr| and |*nvbuf_ptr| are
* expanded as necessary.
*
* This function returns the number of the bytes for the frame
* containing this name/value pairs if it succeeds, or one of the
* following negative error codes:
*
* SPDYLAY_ERR_ZLIB
* The deflate operation failed.
* SPDYLAY_ERR_NOMEM
* Out of memory.
*/
ssize_t spdylay_frame_alloc_pack_nv(uint8_t **buf_ptr,
size_t *buflen_ptr,
uint8_t **nvbuf_ptr,
size_t *nvbuflen_ptr,
char **nv, size_t nv_offset,
size_t len_size,
spdylay_zlib *deflater);
/*
* Counts number of name/value pair in |in| and computes length of
* buffers to store unpacked name/value pair and store them in
@ -440,6 +463,31 @@ int spdylay_frame_count_unpack_nv_space
int spdylay_frame_unpack_nv(char ***nv_ptr, const uint8_t *in, size_t inlen,
size_t len_size);
/*
* Unpacks name/value pairs from buffer |in| with length |inlen|. The
* necessary memory area required for output is allocated and its
* pointer is assigned to |nv_ptr|. |inflatebuf| is used for inflate
* operation. |*nvbuf_ptr| is used for temporarily stored inflated
* name/value pair in wire format. It is expanded as necessary.
* |len_size| is the number of bytes used in name/value length. It
* must be either 2 or 4.
*
* This function returns 0 if it succeeds, or one of the following
* negative error codes:
*
* SPDYLAY_ERR_ZLIB
* The inflate operation failed.
* SPDYLAY_ERR_NOMEM
* Out of memory.
*/
int spdylay_frame_alloc_unpack_nv(char ***nv_ptr,
spdylay_buffer *inflatebuf,
uint8_t **nvbuf_ptr,
size_t *nvbuflen_ptr,
const uint8_t *in, size_t inlen,
size_t len_size,
spdylay_zlib *inflater);
/*
* Initializes SYN_STREAM frame |frame| with given values. |frame|
* takes ownership of |nv|, so caller must not free it. If stream_id