Remove nghttp2_ prefix from static function, part 2

This commit is contained in:
Tatsuhiro Tsujikawa 2014-05-08 23:54:07 +09:00
parent 65bbdf56cd
commit 3ebb3faf32
4 changed files with 93 additions and 96 deletions

View File

@ -96,8 +96,7 @@ void nghttp2_buf_wrap_init(nghttp2_buf *buf, uint8_t *begin, size_t len)
buf->end = begin + len; buf->end = begin + len;
} }
static int nghttp2_buf_chain_new(nghttp2_buf_chain **chain, static int buf_chain_new(nghttp2_buf_chain **chain, size_t chunk_length)
size_t chunk_length)
{ {
int rv; int rv;
@ -117,7 +116,7 @@ static int nghttp2_buf_chain_new(nghttp2_buf_chain **chain,
return 0; return 0;
} }
static void nghttp2_buf_chain_del(nghttp2_buf_chain *chain) static void buf_chain_del(nghttp2_buf_chain *chain)
{ {
nghttp2_buf_free(&chain->buf); nghttp2_buf_free(&chain->buf);
free(chain); free(chain);
@ -145,7 +144,7 @@ int nghttp2_bufs_init3(nghttp2_bufs *bufs, size_t chunk_length,
return NGHTTP2_ERR_INVALID_ARGUMENT; return NGHTTP2_ERR_INVALID_ARGUMENT;
} }
rv = nghttp2_buf_chain_new(&chain, chunk_length); rv = buf_chain_new(&chain, chunk_length);
if(rv != 0) { if(rv != 0) {
return rv; return rv;
} }
@ -172,7 +171,7 @@ void nghttp2_bufs_free(nghttp2_bufs *bufs)
for(chain = bufs->head; chain;) { for(chain = bufs->head; chain;) {
next_chain = chain->next; next_chain = chain->next;
nghttp2_buf_chain_del(chain); buf_chain_del(chain);
chain = next_chain; chain = next_chain;
} }
@ -204,13 +203,13 @@ ssize_t nghttp2_bufs_len(nghttp2_bufs *bufs)
return len; return len;
} }
static int nghttp2_bufs_avail(nghttp2_bufs *bufs) static int bufs_avail(nghttp2_bufs *bufs)
{ {
return nghttp2_buf_avail(&bufs->cur->buf) + return nghttp2_buf_avail(&bufs->cur->buf) +
(bufs->chunk_length - bufs->offset) * (bufs->max_chunk - bufs->chunk_used); (bufs->chunk_length - bufs->offset) * (bufs->max_chunk - bufs->chunk_used);
} }
static int nghttp2_bufs_alloc_chain(nghttp2_bufs *bufs) static int bufs_alloc_chain(nghttp2_bufs *bufs)
{ {
int rv; int rv;
nghttp2_buf_chain *chain; nghttp2_buf_chain *chain;
@ -225,7 +224,7 @@ static int nghttp2_bufs_alloc_chain(nghttp2_bufs *bufs)
return NGHTTP2_ERR_BUFFER_ERROR; return NGHTTP2_ERR_BUFFER_ERROR;
} }
rv = nghttp2_buf_chain_new(&chain, bufs->chunk_length); rv = buf_chain_new(&chain, bufs->chunk_length);
if(rv != 0) { if(rv != 0) {
return rv; return rv;
} }
@ -251,7 +250,7 @@ int nghttp2_bufs_add(nghttp2_bufs *bufs, const void *data, size_t len)
nghttp2_buf *buf; nghttp2_buf *buf;
const uint8_t *p; const uint8_t *p;
if(nghttp2_bufs_avail(bufs) < (ssize_t)len) { if(bufs_avail(bufs) < (ssize_t)len) {
return NGHTTP2_ERR_BUFFER_ERROR; return NGHTTP2_ERR_BUFFER_ERROR;
} }
@ -262,7 +261,7 @@ int nghttp2_bufs_add(nghttp2_bufs *bufs, const void *data, size_t len)
nwrite = nghttp2_min((size_t)nghttp2_buf_avail(buf), len); nwrite = nghttp2_min((size_t)nghttp2_buf_avail(buf), len);
if(nwrite == 0) { if(nwrite == 0) {
rv = nghttp2_bufs_alloc_chain(bufs); rv = bufs_alloc_chain(bufs);
if(rv != 0) { if(rv != 0) {
return rv; return rv;
} }
@ -277,7 +276,7 @@ int nghttp2_bufs_add(nghttp2_bufs *bufs, const void *data, size_t len)
return 0; return 0;
} }
static int nghttp2_bufs_ensure_addb(nghttp2_bufs *bufs) static int bufs_ensure_addb(nghttp2_bufs *bufs)
{ {
int rv; int rv;
nghttp2_buf *buf; nghttp2_buf *buf;
@ -288,7 +287,7 @@ static int nghttp2_bufs_ensure_addb(nghttp2_bufs *bufs)
return 0; return 0;
} }
rv = nghttp2_bufs_alloc_chain(bufs); rv = bufs_alloc_chain(bufs);
if(rv != 0) { if(rv != 0) {
return rv; return rv;
} }
@ -300,7 +299,7 @@ int nghttp2_bufs_addb(nghttp2_bufs *bufs, uint8_t b)
{ {
int rv; int rv;
rv = nghttp2_bufs_ensure_addb(bufs); rv = bufs_ensure_addb(bufs);
if(rv != 0) { if(rv != 0) {
return rv; return rv;
} }
@ -314,7 +313,7 @@ int nghttp2_bufs_addb_hold(nghttp2_bufs *bufs, uint8_t b)
{ {
int rv; int rv;
rv = nghttp2_bufs_ensure_addb(bufs); rv = bufs_ensure_addb(bufs);
if(rv != 0) { if(rv != 0) {
return rv; return rv;
} }
@ -328,7 +327,7 @@ int nghttp2_bufs_orb(nghttp2_bufs *bufs, uint8_t b)
{ {
int rv; int rv;
rv = nghttp2_bufs_ensure_addb(bufs); rv = bufs_ensure_addb(bufs);
if(rv != 0) { if(rv != 0) {
return rv; return rv;
} }
@ -342,7 +341,7 @@ int nghttp2_bufs_orb_hold(nghttp2_bufs *bufs, uint8_t b)
{ {
int rv; int rv;
rv = nghttp2_bufs_ensure_addb(bufs); rv = bufs_ensure_addb(bufs);
if(rv != 0) { if(rv != 0) {
return rv; return rv;
} }
@ -416,7 +415,7 @@ void nghttp2_bufs_reset(nghttp2_bufs *bufs)
for(ci = chain; ci;) { for(ci = chain; ci;) {
chain = ci->next; chain = ci->next;
nghttp2_buf_chain_del(ci); buf_chain_del(ci);
ci = chain; ci = chain;
} }
@ -429,7 +428,7 @@ void nghttp2_bufs_reset(nghttp2_bufs *bufs)
int nghttp2_bufs_advance(nghttp2_bufs *bufs) int nghttp2_bufs_advance(nghttp2_bufs *bufs)
{ {
return nghttp2_bufs_alloc_chain(bufs); return bufs_alloc_chain(bufs);
} }
int nghttp2_bufs_next_present(nghttp2_bufs *bufs) int nghttp2_bufs_next_present(nghttp2_bufs *bufs)

View File

@ -54,7 +54,7 @@ void nghttp2_frame_unpack_frame_hd(nghttp2_frame_hd *hd, const uint8_t* buf)
hd->stream_id = nghttp2_get_uint32(&buf[4]) & NGHTTP2_STREAM_ID_MASK; hd->stream_id = nghttp2_get_uint32(&buf[4]) & NGHTTP2_STREAM_ID_MASK;
} }
static void nghttp2_frame_set_hd(nghttp2_frame_hd *hd, uint16_t length, static void frame_set_hd(nghttp2_frame_hd *hd, uint16_t length,
uint8_t type, uint8_t flags, uint8_t type, uint8_t flags,
int32_t stream_id) int32_t stream_id)
{ {
@ -70,7 +70,7 @@ void nghttp2_frame_headers_init(nghttp2_headers *frame,
const nghttp2_priority_spec *pri_spec, const nghttp2_priority_spec *pri_spec,
nghttp2_nv *nva, size_t nvlen) nghttp2_nv *nva, size_t nvlen)
{ {
nghttp2_frame_set_hd(&frame->hd, 0, NGHTTP2_HEADERS, flags, stream_id); frame_set_hd(&frame->hd, 0, NGHTTP2_HEADERS, flags, stream_id);
frame->padlen = 0; frame->padlen = 0;
frame->nva = nva; frame->nva = nva;
frame->nvlen = nvlen; frame->nvlen = nvlen;
@ -91,7 +91,7 @@ void nghttp2_frame_headers_free(nghttp2_headers *frame)
void nghttp2_frame_priority_init(nghttp2_priority *frame, int32_t stream_id, void nghttp2_frame_priority_init(nghttp2_priority *frame, int32_t stream_id,
const nghttp2_priority_spec *pri_spec) const nghttp2_priority_spec *pri_spec)
{ {
nghttp2_frame_set_hd(&frame->hd, 5, NGHTTP2_PRIORITY, NGHTTP2_FLAG_NONE, frame_set_hd(&frame->hd, 5, NGHTTP2_PRIORITY, NGHTTP2_FLAG_NONE,
stream_id); stream_id);
frame->pri_spec = *pri_spec; frame->pri_spec = *pri_spec;
} }
@ -103,7 +103,7 @@ void nghttp2_frame_rst_stream_init(nghttp2_rst_stream *frame,
int32_t stream_id, int32_t stream_id,
nghttp2_error_code error_code) nghttp2_error_code error_code)
{ {
nghttp2_frame_set_hd(&frame->hd, 4, NGHTTP2_RST_STREAM, NGHTTP2_FLAG_NONE, frame_set_hd(&frame->hd, 4, NGHTTP2_RST_STREAM, NGHTTP2_FLAG_NONE,
stream_id); stream_id);
frame->error_code = error_code; frame->error_code = error_code;
} }
@ -115,7 +115,7 @@ void nghttp2_frame_rst_stream_free(nghttp2_rst_stream *frame)
void nghttp2_frame_settings_init(nghttp2_settings *frame, uint8_t flags, void nghttp2_frame_settings_init(nghttp2_settings *frame, uint8_t flags,
nghttp2_settings_entry *iv, size_t niv) nghttp2_settings_entry *iv, size_t niv)
{ {
nghttp2_frame_set_hd(&frame->hd, niv * NGHTTP2_FRAME_SETTINGS_ENTRY_LENGTH, frame_set_hd(&frame->hd, niv * NGHTTP2_FRAME_SETTINGS_ENTRY_LENGTH,
NGHTTP2_SETTINGS, flags, 0); NGHTTP2_SETTINGS, flags, 0);
frame->niv = niv; frame->niv = niv;
frame->iv = iv; frame->iv = iv;
@ -131,7 +131,7 @@ void nghttp2_frame_push_promise_init(nghttp2_push_promise *frame,
int32_t promised_stream_id, int32_t promised_stream_id,
nghttp2_nv *nva, size_t nvlen) nghttp2_nv *nva, size_t nvlen)
{ {
nghttp2_frame_set_hd(&frame->hd, 0, NGHTTP2_PUSH_PROMISE, flags, stream_id); frame_set_hd(&frame->hd, 0, NGHTTP2_PUSH_PROMISE, flags, stream_id);
frame->padlen = 0; frame->padlen = 0;
frame->nva = nva; frame->nva = nva;
frame->nvlen = nvlen; frame->nvlen = nvlen;
@ -146,7 +146,7 @@ void nghttp2_frame_push_promise_free(nghttp2_push_promise *frame)
void nghttp2_frame_ping_init(nghttp2_ping *frame, uint8_t flags, void nghttp2_frame_ping_init(nghttp2_ping *frame, uint8_t flags,
const uint8_t *opaque_data) const uint8_t *opaque_data)
{ {
nghttp2_frame_set_hd(&frame->hd, 8, NGHTTP2_PING, flags, 0); frame_set_hd(&frame->hd, 8, NGHTTP2_PING, flags, 0);
if(opaque_data) { if(opaque_data) {
memcpy(frame->opaque_data, opaque_data, sizeof(frame->opaque_data)); memcpy(frame->opaque_data, opaque_data, sizeof(frame->opaque_data));
} else { } else {
@ -161,7 +161,7 @@ void nghttp2_frame_goaway_init(nghttp2_goaway *frame, int32_t last_stream_id,
nghttp2_error_code error_code, nghttp2_error_code error_code,
uint8_t *opaque_data, size_t opaque_data_len) uint8_t *opaque_data, size_t opaque_data_len)
{ {
nghttp2_frame_set_hd(&frame->hd, 8+opaque_data_len, NGHTTP2_GOAWAY, frame_set_hd(&frame->hd, 8+opaque_data_len, NGHTTP2_GOAWAY,
NGHTTP2_FLAG_NONE, 0); NGHTTP2_FLAG_NONE, 0);
frame->last_stream_id = last_stream_id; frame->last_stream_id = last_stream_id;
frame->error_code = error_code; frame->error_code = error_code;
@ -179,7 +179,7 @@ void nghttp2_frame_window_update_init(nghttp2_window_update *frame,
int32_t stream_id, int32_t stream_id,
int32_t window_size_increment) int32_t window_size_increment)
{ {
nghttp2_frame_set_hd(&frame->hd, 4, NGHTTP2_WINDOW_UPDATE, flags, stream_id); frame_set_hd(&frame->hd, 4, NGHTTP2_WINDOW_UPDATE, flags, stream_id);
frame->window_size_increment = window_size_increment; frame->window_size_increment = window_size_increment;
} }
@ -199,8 +199,8 @@ void nghttp2_frame_altsvc_init(nghttp2_altsvc *frame, int32_t stream_id,
/* 8 for Max-Age, Port, Reserved and PID_LEN. 1 for HOST_LEN. */ /* 8 for Max-Age, Port, Reserved and PID_LEN. 1 for HOST_LEN. */
payloadlen = 8 + protocol_id_len + 1 + host_len + origin_len; payloadlen = 8 + protocol_id_len + 1 + host_len + origin_len;
nghttp2_frame_set_hd(&frame->hd, payloadlen, NGHTTP2_ALTSVC, frame_set_hd(&frame->hd, payloadlen, NGHTTP2_ALTSVC, NGHTTP2_FLAG_NONE,
NGHTTP2_FLAG_NONE, stream_id); stream_id);
frame->max_age = max_age; frame->max_age = max_age;
frame->port = port; frame->port = port;
@ -219,7 +219,7 @@ void nghttp2_frame_altsvc_free(nghttp2_altsvc *frame)
void nghttp2_frame_blocked_init(nghttp2_blocked *frame, int32_t stream_id) void nghttp2_frame_blocked_init(nghttp2_blocked *frame, int32_t stream_id)
{ {
nghttp2_frame_set_hd(&frame->hd, 0, NGHTTP2_BLOCKED, NGHTTP2_FLAG_NONE, frame_set_hd(&frame->hd, 0, NGHTTP2_BLOCKED, NGHTTP2_FLAG_NONE,
stream_id); stream_id);
} }
@ -251,7 +251,7 @@ void nghttp2_frame_private_data_init(nghttp2_private_data *frame,
const nghttp2_data_provider *data_prd) const nghttp2_data_provider *data_prd)
{ {
/* At this moment, the length of DATA frame is unknown */ /* At this moment, the length of DATA frame is unknown */
nghttp2_frame_set_hd(&frame->hd, 0, NGHTTP2_DATA, flags, stream_id); frame_set_hd(&frame->hd, 0, NGHTTP2_DATA, flags, stream_id);
frame->data_prd = *data_prd; frame->data_prd = *data_prd;
frame->padlen = 0; frame->padlen = 0;
frame->eof = 0; frame->eof = 0;

View File

@ -213,8 +213,7 @@ void nghttp2_hd_entry_free(nghttp2_hd_entry *ent)
} }
} }
static int nghttp2_hd_ringbuf_init(nghttp2_hd_ringbuf *ringbuf, static int hd_ringbuf_init(nghttp2_hd_ringbuf *ringbuf, size_t bufsize)
size_t bufsize)
{ {
size_t size; size_t size;
for(size = 1; size < bufsize; size <<= 1); for(size = 1; size < bufsize; size <<= 1);
@ -228,15 +227,14 @@ static int nghttp2_hd_ringbuf_init(nghttp2_hd_ringbuf *ringbuf,
return 0; return 0;
} }
static nghttp2_hd_entry* nghttp2_hd_ringbuf_get(nghttp2_hd_ringbuf *ringbuf, static nghttp2_hd_entry* hd_ringbuf_get(nghttp2_hd_ringbuf *ringbuf,
size_t index) size_t index)
{ {
assert(index < ringbuf->len); assert(index < ringbuf->len);
return ringbuf->buffer[(ringbuf->first + index) & ringbuf->mask]; return ringbuf->buffer[(ringbuf->first + index) & ringbuf->mask];
} }
static int nghttp2_hd_ringbuf_reserve(nghttp2_hd_ringbuf *ringbuf, static int hd_ringbuf_reserve(nghttp2_hd_ringbuf *ringbuf, size_t bufsize)
size_t bufsize)
{ {
size_t i; size_t i;
size_t size; size_t size;
@ -251,7 +249,7 @@ static int nghttp2_hd_ringbuf_reserve(nghttp2_hd_ringbuf *ringbuf,
return NGHTTP2_ERR_NOMEM; return NGHTTP2_ERR_NOMEM;
} }
for(i = 0; i < ringbuf->len; ++i) { for(i = 0; i < ringbuf->len; ++i) {
buffer[i] = nghttp2_hd_ringbuf_get(ringbuf, i); buffer[i] = hd_ringbuf_get(ringbuf, i);
} }
free(ringbuf->buffer); free(ringbuf->buffer);
ringbuf->buffer = buffer; ringbuf->buffer = buffer;
@ -260,14 +258,14 @@ static int nghttp2_hd_ringbuf_reserve(nghttp2_hd_ringbuf *ringbuf,
return 0; return 0;
} }
static void nghttp2_hd_ringbuf_free(nghttp2_hd_ringbuf *ringbuf) static void hd_ringbuf_free(nghttp2_hd_ringbuf *ringbuf)
{ {
size_t i; size_t i;
if(ringbuf == NULL) { if(ringbuf == NULL) {
return; return;
} }
for(i = 0; i < ringbuf->len; ++i) { for(i = 0; i < ringbuf->len; ++i) {
nghttp2_hd_entry *ent = nghttp2_hd_ringbuf_get(ringbuf, i); nghttp2_hd_entry *ent = hd_ringbuf_get(ringbuf, i);
--ent->ref; --ent->ref;
nghttp2_hd_entry_free(ent); nghttp2_hd_entry_free(ent);
free(ent); free(ent);
@ -275,7 +273,7 @@ static void nghttp2_hd_ringbuf_free(nghttp2_hd_ringbuf *ringbuf)
free(ringbuf->buffer); free(ringbuf->buffer);
} }
static size_t nghttp2_hd_ringbuf_push_front(nghttp2_hd_ringbuf *ringbuf, static size_t hd_ringbuf_push_front(nghttp2_hd_ringbuf *ringbuf,
nghttp2_hd_entry *ent) nghttp2_hd_entry *ent)
{ {
assert(ringbuf->len <= ringbuf->mask); assert(ringbuf->len <= ringbuf->mask);
@ -284,20 +282,20 @@ static size_t nghttp2_hd_ringbuf_push_front(nghttp2_hd_ringbuf *ringbuf,
return 0; return 0;
} }
static void nghttp2_hd_ringbuf_pop_back(nghttp2_hd_ringbuf *ringbuf) static void hd_ringbuf_pop_back(nghttp2_hd_ringbuf *ringbuf)
{ {
assert(ringbuf->len > 0); assert(ringbuf->len > 0);
--ringbuf->len; --ringbuf->len;
} }
static int nghttp2_hd_context_init(nghttp2_hd_context *context, static int hd_context_init(nghttp2_hd_context *context,
nghttp2_hd_role role) nghttp2_hd_role role)
{ {
int rv; int rv;
context->role = role; context->role = role;
context->bad = 0; context->bad = 0;
context->hd_table_bufsize_max = NGHTTP2_HD_DEFAULT_MAX_BUFFER_SIZE; context->hd_table_bufsize_max = NGHTTP2_HD_DEFAULT_MAX_BUFFER_SIZE;
rv = nghttp2_hd_ringbuf_init rv = hd_ringbuf_init
(&context->hd_table, (&context->hd_table,
context->hd_table_bufsize_max/NGHTTP2_HD_ENTRY_OVERHEAD); context->hd_table_bufsize_max/NGHTTP2_HD_ENTRY_OVERHEAD);
if(rv != 0) { if(rv != 0) {
@ -308,9 +306,9 @@ static int nghttp2_hd_context_init(nghttp2_hd_context *context,
return 0; return 0;
} }
static void nghttp2_hd_context_free(nghttp2_hd_context *context) static void hd_context_free(nghttp2_hd_context *context)
{ {
nghttp2_hd_ringbuf_free(&context->hd_table); hd_ringbuf_free(&context->hd_table);
} }
int nghttp2_hd_deflate_init(nghttp2_hd_deflater *deflater) int nghttp2_hd_deflate_init(nghttp2_hd_deflater *deflater)
@ -323,7 +321,7 @@ int nghttp2_hd_deflate_init2(nghttp2_hd_deflater *deflater,
size_t deflate_hd_table_bufsize_max) size_t deflate_hd_table_bufsize_max)
{ {
int rv; int rv;
rv = nghttp2_hd_context_init(&deflater->ctx, NGHTTP2_HD_ROLE_DEFLATE); rv = hd_context_init(&deflater->ctx, NGHTTP2_HD_ROLE_DEFLATE);
if(rv != 0) { if(rv != 0) {
return rv; return rv;
} }
@ -336,7 +334,7 @@ int nghttp2_hd_inflate_init(nghttp2_hd_inflater *inflater)
{ {
int rv; int rv;
rv = nghttp2_hd_context_init(&inflater->ctx, NGHTTP2_HD_ROLE_INFLATE); rv = hd_context_init(&inflater->ctx, NGHTTP2_HD_ROLE_INFLATE);
if(rv != 0) { if(rv != 0) {
goto fail; goto fail;
} }
@ -376,7 +374,7 @@ int nghttp2_hd_inflate_init(nghttp2_hd_inflater *inflater)
valuebuf_fail: valuebuf_fail:
nghttp2_bufs_free(&inflater->namebufs); nghttp2_bufs_free(&inflater->namebufs);
namebuf_fail: namebuf_fail:
nghttp2_hd_context_free(&inflater->ctx); hd_context_free(&inflater->ctx);
fail: fail:
return rv; return rv;
} }
@ -398,7 +396,7 @@ static void hd_inflate_keep_free(nghttp2_hd_inflater *inflater)
void nghttp2_hd_deflate_free(nghttp2_hd_deflater *deflater) void nghttp2_hd_deflate_free(nghttp2_hd_deflater *deflater)
{ {
nghttp2_hd_context_free(&deflater->ctx); hd_context_free(&deflater->ctx);
} }
void nghttp2_hd_inflate_free(nghttp2_hd_inflater *inflater) void nghttp2_hd_inflate_free(nghttp2_hd_inflater *inflater)
@ -406,7 +404,7 @@ void nghttp2_hd_inflate_free(nghttp2_hd_inflater *inflater)
hd_inflate_keep_free(inflater); hd_inflate_keep_free(inflater);
nghttp2_bufs_free(&inflater->namebufs); nghttp2_bufs_free(&inflater->namebufs);
nghttp2_bufs_free(&inflater->valuebufs); nghttp2_bufs_free(&inflater->valuebufs);
nghttp2_hd_context_free(&inflater->ctx); hd_context_free(&inflater->ctx);
} }
void nghttp2_hd_deflate_set_no_refset(nghttp2_hd_deflater *deflater, void nghttp2_hd_deflate_set_no_refset(nghttp2_hd_deflater *deflater,
@ -552,7 +550,7 @@ static uint8_t* decode_length(ssize_t *res, int *final, ssize_t initial,
return in + 1; return in + 1;
} }
static int nghttp2_hd_handle_buffer_error(int rv) static int hd_handle_buffer_error(int rv)
{ {
if(rv == NGHTTP2_ERR_BUFFER_ERROR) { if(rv == NGHTTP2_ERR_BUFFER_ERROR) {
return NGHTTP2_ERR_HEADER_COMP; return NGHTTP2_ERR_HEADER_COMP;
@ -568,7 +566,7 @@ static int emit_clear_refset(nghttp2_bufs *bufs)
rv = nghttp2_bufs_addb(bufs, 0x30u); rv = nghttp2_bufs_addb(bufs, 0x30u);
if(rv != 0) { if(rv != 0) {
return nghttp2_hd_handle_buffer_error(rv); return hd_handle_buffer_error(rv);
} }
return 0; return 0;
@ -597,7 +595,7 @@ static int emit_table_size(nghttp2_bufs *bufs, size_t table_size)
rv = nghttp2_bufs_add(bufs, sb, blocklen); rv = nghttp2_bufs_add(bufs, sb, blocklen);
if(rv != 0) { if(rv != 0) {
return nghttp2_hd_handle_buffer_error(rv); return hd_handle_buffer_error(rv);
} }
return 0; return 0;
@ -625,7 +623,7 @@ static int emit_indexed_block(nghttp2_bufs *bufs, size_t index)
rv = nghttp2_bufs_add(bufs, sb, blocklen); rv = nghttp2_bufs_add(bufs, sb, blocklen);
if(rv != 0) { if(rv != 0) {
return nghttp2_hd_handle_buffer_error(rv); return hd_handle_buffer_error(rv);
} }
return 0; return 0;
@ -658,7 +656,7 @@ static int emit_string(nghttp2_bufs *bufs,
rv = nghttp2_bufs_add(bufs, sb, blocklen); rv = nghttp2_bufs_add(bufs, sb, blocklen);
if(rv != 0) { if(rv != 0) {
return nghttp2_hd_handle_buffer_error(rv); return hd_handle_buffer_error(rv);
} }
if(huffman) { if(huffman) {
@ -668,7 +666,7 @@ static int emit_string(nghttp2_bufs *bufs,
rv = nghttp2_bufs_add(bufs, str, len); rv = nghttp2_bufs_add(bufs, str, len);
} }
return nghttp2_hd_handle_buffer_error(rv); return hd_handle_buffer_error(rv);
} }
static uint8_t pack_first_byte(int inc_indexing, int no_index) static uint8_t pack_first_byte(int inc_indexing, int no_index)
@ -730,7 +728,7 @@ static int emit_indname_block(nghttp2_bufs *bufs, size_t index,
rv = nghttp2_bufs_add(bufs, sb, blocklen); rv = nghttp2_bufs_add(bufs, sb, blocklen);
if(rv != 0) { if(rv != 0) {
return nghttp2_hd_handle_buffer_error(rv); return hd_handle_buffer_error(rv);
} }
rv = emit_string(bufs, encvallen, huffman, nv->value, nv->valuelen); rv = emit_string(bufs, encvallen, huffman, nv->value, nv->valuelen);
@ -772,7 +770,7 @@ static int emit_newname_block(nghttp2_bufs *bufs, nghttp2_nv *nv,
rv = nghttp2_bufs_addb(bufs, pack_first_byte(inc_indexing, no_index)); rv = nghttp2_bufs_addb(bufs, pack_first_byte(inc_indexing, no_index));
if(rv != 0) { if(rv != 0) {
return nghttp2_hd_handle_buffer_error(rv); return hd_handle_buffer_error(rv);
} }
rv = emit_string(bufs, encnamelen, name_huffman, nv->name, nv->namelen); rv = emit_string(bufs, encnamelen, name_huffman, nv->name, nv->namelen);
@ -820,7 +818,7 @@ static nghttp2_hd_entry* add_hd_table_incremental(nghttp2_hd_context *context,
context->hd_table.len > 0) { context->hd_table.len > 0) {
size_t index = context->hd_table.len - 1; size_t index = context->hd_table.len - 1;
nghttp2_hd_entry* ent = nghttp2_hd_ringbuf_get(&context->hd_table, index); nghttp2_hd_entry* ent = hd_ringbuf_get(&context->hd_table, index);
context->hd_table_bufsize -= entry_room(ent->nv.namelen, ent->nv.valuelen); context->hd_table_bufsize -= entry_room(ent->nv.namelen, ent->nv.valuelen);
if(context->role == NGHTTP2_HD_ROLE_DEFLATE) { if(context->role == NGHTTP2_HD_ROLE_DEFLATE) {
@ -839,7 +837,7 @@ static nghttp2_hd_entry* add_hd_table_incremental(nghttp2_hd_context *context,
DEBUGF(fprintf(stderr, ": ")); DEBUGF(fprintf(stderr, ": "));
DEBUGF(fwrite(ent->nv.value, ent->nv.valuelen, 1, stderr)); DEBUGF(fwrite(ent->nv.value, ent->nv.valuelen, 1, stderr));
DEBUGF(fprintf(stderr, "\n")); DEBUGF(fprintf(stderr, "\n"));
nghttp2_hd_ringbuf_pop_back(&context->hd_table); hd_ringbuf_pop_back(&context->hd_table);
if(--ent->ref == 0) { if(--ent->ref == 0) {
nghttp2_hd_entry_free(ent); nghttp2_hd_entry_free(ent);
free(ent); free(ent);
@ -864,7 +862,7 @@ static nghttp2_hd_entry* add_hd_table_incremental(nghttp2_hd_context *context,
--new_ent->ref; --new_ent->ref;
} else { } else {
context->hd_table_bufsize += room; context->hd_table_bufsize += room;
nghttp2_hd_ringbuf_push_front(&context->hd_table, new_ent); hd_ringbuf_push_front(&context->hd_table, new_ent);
new_ent->flags |= NGHTTP2_HD_FLAG_REFSET; new_ent->flags |= NGHTTP2_HD_FLAG_REFSET;
} }
@ -899,7 +897,7 @@ static search_result search_hd_table(nghttp2_hd_context *context,
if(use_index) { if(use_index) {
for(i = 0; i < context->hd_table.len; ++i) { for(i = 0; i < context->hd_table.len; ++i) {
nghttp2_hd_entry *ent = nghttp2_hd_ringbuf_get(&context->hd_table, i); nghttp2_hd_entry *ent = hd_ringbuf_get(&context->hd_table, i);
if(ent->name_hash == name_hash && name_eq(&ent->nv, nv)) { if(ent->name_hash == name_hash && name_eq(&ent->nv, nv)) {
if(res.index == -1) { if(res.index == -1) {
res.index = i; res.index = i;
@ -948,9 +946,9 @@ static void hd_context_shrink_table_size(nghttp2_hd_context *context)
while(context->hd_table_bufsize > context->hd_table_bufsize_max && while(context->hd_table_bufsize > context->hd_table_bufsize_max &&
context->hd_table.len > 0) { context->hd_table.len > 0) {
size_t index = context->hd_table.len - 1; size_t index = context->hd_table.len - 1;
nghttp2_hd_entry* ent = nghttp2_hd_ringbuf_get(&context->hd_table, index); nghttp2_hd_entry* ent = hd_ringbuf_get(&context->hd_table, index);
context->hd_table_bufsize -= entry_room(ent->nv.namelen, ent->nv.valuelen); context->hd_table_bufsize -= entry_room(ent->nv.namelen, ent->nv.valuelen);
nghttp2_hd_ringbuf_pop_back(&context->hd_table); hd_ringbuf_pop_back(&context->hd_table);
if(--ent->ref == 0) { if(--ent->ref == 0) {
nghttp2_hd_entry_free(ent); nghttp2_hd_entry_free(ent);
free(ent); free(ent);
@ -964,7 +962,7 @@ int nghttp2_hd_deflate_change_table_size(nghttp2_hd_deflater *deflater,
int rv; int rv;
size_t next_bufsize = nghttp2_min(settings_hd_table_bufsize_max, size_t next_bufsize = nghttp2_min(settings_hd_table_bufsize_max,
deflater->deflate_hd_table_bufsize_max); deflater->deflate_hd_table_bufsize_max);
rv = nghttp2_hd_ringbuf_reserve rv = hd_ringbuf_reserve
(&deflater->ctx.hd_table, next_bufsize / NGHTTP2_HD_ENTRY_OVERHEAD); (&deflater->ctx.hd_table, next_bufsize / NGHTTP2_HD_ENTRY_OVERHEAD);
if(rv != 0) { if(rv != 0) {
return rv; return rv;
@ -987,7 +985,7 @@ int nghttp2_hd_inflate_change_table_size(nghttp2_hd_inflater *inflater,
{ {
int rv; int rv;
rv = nghttp2_hd_ringbuf_reserve rv = hd_ringbuf_reserve
(&inflater->ctx.hd_table, (&inflater->ctx.hd_table,
settings_hd_table_bufsize_max / NGHTTP2_HD_ENTRY_OVERHEAD); settings_hd_table_bufsize_max / NGHTTP2_HD_ENTRY_OVERHEAD);
if(rv != 0) { if(rv != 0) {
@ -1003,7 +1001,7 @@ static void clear_refset(nghttp2_hd_context *context)
{ {
size_t i; size_t i;
for(i = 0; i < context->hd_table.len; ++i) { for(i = 0; i < context->hd_table.len; ++i) {
nghttp2_hd_entry *ent = nghttp2_hd_ringbuf_get(&context->hd_table, i); nghttp2_hd_entry *ent = hd_ringbuf_get(&context->hd_table, i);
ent->flags &= ~NGHTTP2_HD_FLAG_REFSET; ent->flags &= ~NGHTTP2_HD_FLAG_REFSET;
} }
} }
@ -1023,7 +1021,7 @@ nghttp2_hd_entry* nghttp2_hd_table_get(nghttp2_hd_context *context,
{ {
assert(check_index_range(context, index)); assert(check_index_range(context, index));
if(index < context->hd_table.len) { if(index < context->hd_table.len) {
return nghttp2_hd_ringbuf_get(&context->hd_table, index); return hd_ringbuf_get(&context->hd_table, index);
} else { } else {
return return
&static_table[static_table_index[index - context->hd_table.len]].ent; &static_table[static_table_index[index - context->hd_table.len]].ent;
@ -1247,7 +1245,7 @@ int nghttp2_hd_deflate_hd(nghttp2_hd_deflater *deflater,
"deflatehd: all input name/value pairs were deflated\n")); "deflatehd: all input name/value pairs were deflated\n"));
for(i = 0; i < deflater->ctx.hd_table.len; ++i) { for(i = 0; i < deflater->ctx.hd_table.len; ++i) {
nghttp2_hd_entry *ent = nghttp2_hd_ringbuf_get(&deflater->ctx.hd_table, i); nghttp2_hd_entry *ent = hd_ringbuf_get(&deflater->ctx.hd_table, i);
rv = deflate_post_process_hd_entry(ent, i, bufs); rv = deflate_post_process_hd_entry(ent, i, bufs);
if(rv != 0) { if(rv != 0) {
@ -1904,7 +1902,7 @@ ssize_t nghttp2_hd_inflate_hd(nghttp2_hd_inflater *inflater,
for(; inflater->end_headers_index < inflater->ctx.hd_table.len; for(; inflater->end_headers_index < inflater->ctx.hd_table.len;
++inflater->end_headers_index) { ++inflater->end_headers_index) {
nghttp2_hd_entry *ent; nghttp2_hd_entry *ent;
ent = nghttp2_hd_ringbuf_get(&inflater->ctx.hd_table, ent = hd_ringbuf_get(&inflater->ctx.hd_table,
inflater->end_headers_index); inflater->end_headers_index);
if((ent->flags & NGHTTP2_HD_FLAG_REFSET) && if((ent->flags & NGHTTP2_HD_FLAG_REFSET) &&

View File

@ -35,7 +35,7 @@
/* This function takes ownership of |nva_copy|. Regardless of the /* This function takes ownership of |nva_copy|. Regardless of the
return value, the caller must not free |nva_copy| after this return value, the caller must not free |nva_copy| after this
function returns. */ function returns. */
static int32_t nghttp2_submit_headers_shared static int32_t submit_headers_shared
(nghttp2_session *session, (nghttp2_session *session,
uint8_t flags, uint8_t flags,
int32_t stream_id, int32_t stream_id,
@ -133,7 +133,7 @@ static void adjust_priority_spec_weight(nghttp2_priority_spec *pri_spec)
} }
} }
static int32_t nghttp2_submit_headers_shared_nva static int32_t submit_headers_shared_nva
(nghttp2_session *session, (nghttp2_session *session,
uint8_t flags, uint8_t flags,
int32_t stream_id, int32_t stream_id,
@ -159,7 +159,7 @@ static int32_t nghttp2_submit_headers_shared_nva
return rv; return rv;
} }
return nghttp2_submit_headers_shared(session, flags, stream_id, return submit_headers_shared(session, flags, stream_id,
&copy_pri_spec, nva_copy, rv, data_prd, &copy_pri_spec, nva_copy, rv, data_prd,
stream_user_data); stream_user_data);
} }
@ -178,7 +178,7 @@ int32_t nghttp2_submit_headers(nghttp2_session *session, uint8_t flags,
pri_spec = NULL; pri_spec = NULL;
} }
return nghttp2_submit_headers_shared_nva(session, flags, stream_id, pri_spec, return submit_headers_shared_nva(session, flags, stream_id, pri_spec,
nva, nvlen, NULL, stream_user_data); nva, nvlen, NULL, stream_user_data);
} }
@ -461,7 +461,7 @@ int32_t nghttp2_submit_request(nghttp2_session *session,
flags = set_request_flags(pri_spec, data_prd); flags = set_request_flags(pri_spec, data_prd);
return nghttp2_submit_headers_shared_nva(session, flags, -1, pri_spec, return submit_headers_shared_nva(session, flags, -1, pri_spec,
nva, nvlen, nva, nvlen,
data_prd, stream_user_data); data_prd, stream_user_data);
} }
@ -481,7 +481,7 @@ int nghttp2_submit_response(nghttp2_session *session,
const nghttp2_data_provider *data_prd) const nghttp2_data_provider *data_prd)
{ {
uint8_t flags = set_response_flags(data_prd); uint8_t flags = set_response_flags(data_prd);
return nghttp2_submit_headers_shared_nva(session, flags, stream_id, return submit_headers_shared_nva(session, flags, stream_id,
NULL, nva, nvlen, NULL, nva, nvlen,
data_prd, NULL); data_prd, NULL);
} }