tests: Use nghttp2_mem instead of raw malloc()/free()
Fixes GH-170
This commit is contained in:
parent
291c27c940
commit
a2a9f15307
|
@ -433,7 +433,7 @@ void test_nghttp2_frame(void) {
|
|||
|
||||
static int deflate_inflate(nghttp2_hd_deflater *deflater,
|
||||
nghttp2_hd_inflater *inflater, nghttp2_bufs *bufs,
|
||||
nghttp2_nv *nva, size_t nvlen) {
|
||||
nghttp2_nv *nva, size_t nvlen, nghttp2_mem *mem) {
|
||||
int rv;
|
||||
|
||||
rv = nghttp2_hd_deflate_hd_bufs(deflater, bufs, nva, nvlen);
|
||||
|
@ -442,7 +442,7 @@ static int deflate_inflate(nghttp2_hd_deflater *deflater,
|
|||
return rv;
|
||||
}
|
||||
|
||||
rv = (int)inflate_hd(inflater, NULL, bufs, 0);
|
||||
rv = (int)inflate_hd(inflater, NULL, bufs, 0, mem);
|
||||
|
||||
if (rv < 0) {
|
||||
return rv;
|
||||
|
@ -484,13 +484,15 @@ static void run_nghttp2_hd(void) {
|
|||
goto inflate_init_fail;
|
||||
}
|
||||
|
||||
rv = deflate_inflate(&deflater, &inflater, &bufs, nva1, ARRLEN(nva1));
|
||||
rv = deflate_inflate(&deflater, &inflater, &bufs, nva1, ARRLEN(nva1),
|
||||
nghttp2_mem_fm());
|
||||
|
||||
if (rv != 0) {
|
||||
goto deflate_hd_fail;
|
||||
}
|
||||
|
||||
rv = deflate_inflate(&deflater, &inflater, &bufs, nva2, ARRLEN(nva2));
|
||||
rv = deflate_inflate(&deflater, &inflater, &bufs, nva2, ARRLEN(nva2),
|
||||
nghttp2_mem_fm());
|
||||
|
||||
if (rv != 0) {
|
||||
goto deflate_hd_fail;
|
||||
|
|
|
@ -201,7 +201,7 @@ void test_nghttp2_bufs_remove(void) {
|
|||
CU_ASSERT(0 == nghttp2_bufs_len(&bufs));
|
||||
CU_ASSERT(bufs.cur->buf.pos == bufs.cur->buf.begin);
|
||||
|
||||
free(out);
|
||||
mem->free(out, NULL);
|
||||
nghttp2_bufs_free(&bufs);
|
||||
}
|
||||
|
||||
|
|
|
@ -47,8 +47,8 @@ static nghttp2_nv make_nv(const char *name, const char *value) {
|
|||
|
||||
#define HEADERS_LENGTH 7
|
||||
|
||||
static nghttp2_nv *headers(void) {
|
||||
nghttp2_nv *nva = malloc(sizeof(nghttp2_nv) * HEADERS_LENGTH);
|
||||
static nghttp2_nv *headers(nghttp2_mem *mem) {
|
||||
nghttp2_nv *nva = mem->malloc(sizeof(nghttp2_nv) * HEADERS_LENGTH, NULL);
|
||||
nva[0] = make_nv("method", "GET");
|
||||
nva[1] = make_nv("scheme", "https");
|
||||
nva[2] = make_nv("url", "/");
|
||||
|
@ -88,7 +88,7 @@ void test_nghttp2_frame_pack_headers() {
|
|||
nghttp2_hd_deflate_init(&deflater, mem);
|
||||
nghttp2_hd_inflate_init(&inflater, mem);
|
||||
|
||||
nva = headers();
|
||||
nva = headers(mem);
|
||||
nvlen = HEADERS_LENGTH;
|
||||
|
||||
nghttp2_priority_spec_default_init(&pri_spec);
|
||||
|
@ -113,14 +113,14 @@ void test_nghttp2_frame_pack_headers() {
|
|||
|
||||
hdblocklen = nghttp2_bufs_len(&bufs) - NGHTTP2_FRAME_HDLEN;
|
||||
CU_ASSERT(hdblocklen ==
|
||||
inflate_hd(&inflater, &out, &bufs, NGHTTP2_FRAME_HDLEN));
|
||||
inflate_hd(&inflater, &out, &bufs, NGHTTP2_FRAME_HDLEN, mem));
|
||||
|
||||
CU_ASSERT(7 == out.nvlen);
|
||||
CU_ASSERT(nvnameeq("method", &out.nva[0]));
|
||||
CU_ASSERT(nvvalueeq("GET", &out.nva[0]));
|
||||
|
||||
nghttp2_frame_headers_free(&oframe, mem);
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
nghttp2_bufs_reset(&bufs);
|
||||
|
||||
memset(&oframe, 0, sizeof(oframe));
|
||||
|
@ -149,13 +149,14 @@ void test_nghttp2_frame_pack_headers() {
|
|||
CU_ASSERT(hdblocklen ==
|
||||
inflate_hd(&inflater, &out, &bufs,
|
||||
NGHTTP2_FRAME_HDLEN +
|
||||
nghttp2_frame_priority_len(oframe.hd.flags)));
|
||||
nghttp2_frame_priority_len(oframe.hd.flags),
|
||||
mem));
|
||||
|
||||
nghttp2_nv_array_sort(out.nva, out.nvlen);
|
||||
CU_ASSERT(nvnameeq("method", &out.nva[0]));
|
||||
|
||||
nghttp2_frame_headers_free(&oframe, mem);
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
nghttp2_bufs_reset(&bufs);
|
||||
|
||||
nghttp2_bufs_free(&bufs);
|
||||
|
@ -181,7 +182,7 @@ void test_nghttp2_frame_pack_headers_frame_too_large(void) {
|
|||
|
||||
for (i = 0; i < big_hdslen; ++i) {
|
||||
big_hds[i].name = (uint8_t *)"header";
|
||||
big_hds[i].value = malloc(big_vallen + 1);
|
||||
big_hds[i].value = mem->malloc(big_vallen + 1, NULL);
|
||||
memset(big_hds[i].value, '0' + (int)i, big_vallen);
|
||||
big_hds[i].value[big_vallen] = '\0';
|
||||
big_hds[i].namelen = strlen((char *)big_hds[i].name);
|
||||
|
@ -200,7 +201,7 @@ void test_nghttp2_frame_pack_headers_frame_too_large(void) {
|
|||
nghttp2_frame_headers_free(&frame, mem);
|
||||
nghttp2_bufs_free(&bufs);
|
||||
for (i = 0; i < big_hdslen; ++i) {
|
||||
free(big_hds[i].value);
|
||||
mem->free(big_hds[i].value, NULL);
|
||||
}
|
||||
nghttp2_hd_deflate_free(&deflater);
|
||||
}
|
||||
|
@ -329,7 +330,7 @@ void test_nghttp2_frame_pack_push_promise() {
|
|||
nghttp2_hd_deflate_init(&deflater, mem);
|
||||
nghttp2_hd_inflate_init(&inflater, mem);
|
||||
|
||||
nva = headers();
|
||||
nva = headers(mem);
|
||||
nvlen = HEADERS_LENGTH;
|
||||
nghttp2_frame_push_promise_init(&frame, NGHTTP2_FLAG_END_HEADERS, 1000000007,
|
||||
(1U << 31) - 1, nva, nvlen);
|
||||
|
@ -346,13 +347,13 @@ void test_nghttp2_frame_pack_push_promise() {
|
|||
|
||||
hdblocklen = nghttp2_bufs_len(&bufs) - NGHTTP2_FRAME_HDLEN - 4;
|
||||
CU_ASSERT(hdblocklen ==
|
||||
inflate_hd(&inflater, &out, &bufs, NGHTTP2_FRAME_HDLEN + 4));
|
||||
inflate_hd(&inflater, &out, &bufs, NGHTTP2_FRAME_HDLEN + 4, mem));
|
||||
|
||||
CU_ASSERT(7 == out.nvlen);
|
||||
CU_ASSERT(nvnameeq("method", &out.nva[0]));
|
||||
CU_ASSERT(nvvalueeq("GET", &out.nva[0]));
|
||||
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
nghttp2_bufs_free(&bufs);
|
||||
nghttp2_frame_push_promise_free(&oframe, mem);
|
||||
nghttp2_frame_push_promise_free(&frame, mem);
|
||||
|
@ -387,13 +388,14 @@ void test_nghttp2_frame_pack_goaway() {
|
|||
nghttp2_goaway frame, oframe;
|
||||
nghttp2_bufs bufs;
|
||||
size_t opaque_data_len = 16;
|
||||
uint8_t *opaque_data = malloc(opaque_data_len);
|
||||
uint8_t *opaque_data;
|
||||
int rv;
|
||||
nghttp2_mem *mem;
|
||||
|
||||
mem = nghttp2_mem_default();
|
||||
frame_pack_bufs_init(&bufs);
|
||||
|
||||
opaque_data = mem->malloc(opaque_data_len, NULL);
|
||||
memcpy(opaque_data, "0123456789abcdef", opaque_data_len);
|
||||
nghttp2_frame_goaway_init(&frame, 1000000007, NGHTTP2_PROTOCOL_ERROR,
|
||||
opaque_data, opaque_data_len);
|
||||
|
@ -465,7 +467,7 @@ void test_nghttp2_nv_array_copy(void) {
|
|||
bignv.name = (uint8_t *)"echo";
|
||||
bignv.namelen = strlen("echo");
|
||||
bignv.valuelen = (1 << 14) - 1;
|
||||
bignv.value = malloc(bignv.valuelen);
|
||||
bignv.value = mem->malloc(bignv.valuelen, NULL);
|
||||
memset(bignv.value, '0', bignv.valuelen);
|
||||
|
||||
rv = nghttp2_nv_array_copy(&nva, NULL, 0, mem);
|
||||
|
@ -500,7 +502,7 @@ void test_nghttp2_nv_array_copy(void) {
|
|||
|
||||
nghttp2_nv_array_del(nva, mem);
|
||||
|
||||
free(bignv.value);
|
||||
mem->free(bignv.value, NULL);
|
||||
}
|
||||
|
||||
void test_nghttp2_iv_check(void) {
|
||||
|
|
|
@ -66,12 +66,12 @@ void test_nghttp2_hd_deflate(void) {
|
|||
|
||||
CU_ASSERT(0 == rv);
|
||||
CU_ASSERT(blocklen > 0);
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0));
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
|
||||
|
||||
CU_ASSERT(3 == out.nvlen);
|
||||
assert_nv_equal(nva1, out.nva, 3);
|
||||
assert_nv_equal(nva1, out.nva, 3, mem);
|
||||
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
nghttp2_bufs_reset(&bufs);
|
||||
|
||||
/* Second headers */
|
||||
|
@ -80,12 +80,12 @@ void test_nghttp2_hd_deflate(void) {
|
|||
|
||||
CU_ASSERT(0 == rv);
|
||||
CU_ASSERT(blocklen > 0);
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0));
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
|
||||
|
||||
CU_ASSERT(2 == out.nvlen);
|
||||
assert_nv_equal(nva2, out.nva, 2);
|
||||
assert_nv_equal(nva2, out.nva, 2, mem);
|
||||
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
nghttp2_bufs_reset(&bufs);
|
||||
|
||||
/* Third headers, including same header field name, but value is not
|
||||
|
@ -95,12 +95,12 @@ void test_nghttp2_hd_deflate(void) {
|
|||
|
||||
CU_ASSERT(0 == rv);
|
||||
CU_ASSERT(blocklen > 0);
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0));
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
|
||||
|
||||
CU_ASSERT(3 == out.nvlen);
|
||||
assert_nv_equal(nva3, out.nva, 3);
|
||||
assert_nv_equal(nva3, out.nva, 3, mem);
|
||||
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
nghttp2_bufs_reset(&bufs);
|
||||
|
||||
/* Fourth headers, including duplicate header fields. */
|
||||
|
@ -109,12 +109,12 @@ void test_nghttp2_hd_deflate(void) {
|
|||
|
||||
CU_ASSERT(0 == rv);
|
||||
CU_ASSERT(blocklen > 0);
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0));
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
|
||||
|
||||
CU_ASSERT(3 == out.nvlen);
|
||||
assert_nv_equal(nva4, out.nva, 3);
|
||||
assert_nv_equal(nva4, out.nva, 3, mem);
|
||||
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
nghttp2_bufs_reset(&bufs);
|
||||
|
||||
/* Fifth headers includes empty value */
|
||||
|
@ -123,12 +123,12 @@ void test_nghttp2_hd_deflate(void) {
|
|||
|
||||
CU_ASSERT(0 == rv);
|
||||
CU_ASSERT(blocklen > 0);
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0));
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
|
||||
|
||||
CU_ASSERT(2 == out.nvlen);
|
||||
assert_nv_equal(nva5, out.nva, 2);
|
||||
assert_nv_equal(nva5, out.nva, 2, mem);
|
||||
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
nghttp2_bufs_reset(&bufs);
|
||||
|
||||
/* Cleanup */
|
||||
|
@ -162,12 +162,12 @@ void test_nghttp2_hd_deflate_same_indexed_repr(void) {
|
|||
|
||||
CU_ASSERT(0 == rv);
|
||||
CU_ASSERT(blocklen > 0);
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0));
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
|
||||
|
||||
CU_ASSERT(2 == out.nvlen);
|
||||
assert_nv_equal(nva1, out.nva, 2);
|
||||
assert_nv_equal(nva1, out.nva, 2, mem);
|
||||
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
nghttp2_bufs_reset(&bufs);
|
||||
|
||||
/* Encode 3 same headers. This time, emits 3 index reprs. */
|
||||
|
@ -176,12 +176,12 @@ void test_nghttp2_hd_deflate_same_indexed_repr(void) {
|
|||
|
||||
CU_ASSERT(0 == rv);
|
||||
CU_ASSERT(blocklen == 3);
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0));
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
|
||||
|
||||
CU_ASSERT(3 == out.nvlen);
|
||||
assert_nv_equal(nva2, out.nva, 3);
|
||||
assert_nv_equal(nva2, out.nva, 3, mem);
|
||||
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
nghttp2_bufs_reset(&bufs);
|
||||
|
||||
/* Cleanup */
|
||||
|
@ -209,13 +209,13 @@ void test_nghttp2_hd_inflate_indexed(void) {
|
|||
blocklen = nghttp2_bufs_len(&bufs);
|
||||
|
||||
CU_ASSERT(1 == blocklen);
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0));
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
|
||||
|
||||
CU_ASSERT(1 == out.nvlen);
|
||||
|
||||
assert_nv_equal(&nv, out.nva, 1);
|
||||
assert_nv_equal(&nv, out.nva, 1, mem);
|
||||
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
nghttp2_bufs_reset(&bufs);
|
||||
|
||||
/* index = 0 is error */
|
||||
|
@ -224,7 +224,8 @@ void test_nghttp2_hd_inflate_indexed(void) {
|
|||
blocklen = nghttp2_bufs_len(&bufs);
|
||||
|
||||
CU_ASSERT(1 == blocklen);
|
||||
CU_ASSERT(NGHTTP2_ERR_HEADER_COMP == inflate_hd(&inflater, &out, &bufs, 0));
|
||||
CU_ASSERT(NGHTTP2_ERR_HEADER_COMP ==
|
||||
inflate_hd(&inflater, &out, &bufs, 0, mem));
|
||||
|
||||
nghttp2_bufs_free(&bufs);
|
||||
nghttp2_hd_inflate_free(&inflater);
|
||||
|
@ -254,13 +255,13 @@ void test_nghttp2_hd_inflate_indname_noinc(void) {
|
|||
blocklen = nghttp2_bufs_len(&bufs);
|
||||
|
||||
CU_ASSERT(blocklen > 0);
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0));
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
|
||||
|
||||
CU_ASSERT(1 == out.nvlen);
|
||||
assert_nv_equal(&nv[i], out.nva, 1);
|
||||
assert_nv_equal(&nv[i], out.nva, 1, mem);
|
||||
CU_ASSERT(0 == inflater.ctx.hd_table.len);
|
||||
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
nghttp2_bufs_reset(&bufs);
|
||||
}
|
||||
|
||||
|
@ -287,17 +288,17 @@ void test_nghttp2_hd_inflate_indname_inc(void) {
|
|||
blocklen = nghttp2_bufs_len(&bufs);
|
||||
|
||||
CU_ASSERT(blocklen > 0);
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0));
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
|
||||
|
||||
CU_ASSERT(1 == out.nvlen);
|
||||
assert_nv_equal(&nv, out.nva, 1);
|
||||
assert_nv_equal(&nv, out.nva, 1, mem);
|
||||
CU_ASSERT(1 == inflater.ctx.hd_table.len);
|
||||
assert_nv_equal(
|
||||
&nv, &GET_TABLE_ENT(&inflater.ctx, NGHTTP2_STATIC_TABLE_LENGTH +
|
||||
inflater.ctx.hd_table.len - 1)->nv,
|
||||
1);
|
||||
1, mem);
|
||||
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
nghttp2_bufs_free(&bufs);
|
||||
nghttp2_hd_inflate_free(&inflater);
|
||||
}
|
||||
|
@ -332,14 +333,14 @@ void test_nghttp2_hd_inflate_indname_inc_eviction(void) {
|
|||
|
||||
CU_ASSERT(blocklen > 0);
|
||||
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0));
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
|
||||
|
||||
CU_ASSERT(4 == out.nvlen);
|
||||
CU_ASSERT(14 == out.nva[0].namelen);
|
||||
CU_ASSERT(0 == memcmp("accept-charset", out.nva[0].name, out.nva[0].namelen));
|
||||
CU_ASSERT(sizeof(value) == out.nva[0].valuelen);
|
||||
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
nghttp2_bufs_reset(&bufs);
|
||||
|
||||
CU_ASSERT(3 == inflater.ctx.hd_table.len);
|
||||
|
@ -375,13 +376,13 @@ void test_nghttp2_hd_inflate_newname_noinc(void) {
|
|||
blocklen = nghttp2_bufs_len(&bufs);
|
||||
|
||||
CU_ASSERT(blocklen > 0);
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0));
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
|
||||
|
||||
CU_ASSERT(1 == out.nvlen);
|
||||
assert_nv_equal(&nv[i], out.nva, 1);
|
||||
assert_nv_equal(&nv[i], out.nva, 1, mem);
|
||||
CU_ASSERT(0 == inflater.ctx.hd_table.len);
|
||||
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
nghttp2_bufs_reset(&bufs);
|
||||
}
|
||||
|
||||
|
@ -408,17 +409,17 @@ void test_nghttp2_hd_inflate_newname_inc(void) {
|
|||
blocklen = nghttp2_bufs_len(&bufs);
|
||||
|
||||
CU_ASSERT(blocklen > 0);
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0));
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
|
||||
|
||||
CU_ASSERT(1 == out.nvlen);
|
||||
assert_nv_equal(&nv, out.nva, 1);
|
||||
assert_nv_equal(&nv, out.nva, 1, mem);
|
||||
CU_ASSERT(1 == inflater.ctx.hd_table.len);
|
||||
assert_nv_equal(
|
||||
&nv, &GET_TABLE_ENT(&inflater.ctx, NGHTTP2_STATIC_TABLE_LENGTH +
|
||||
inflater.ctx.hd_table.len - 1)->nv,
|
||||
1);
|
||||
1, mem);
|
||||
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
nghttp2_bufs_free(&bufs);
|
||||
nghttp2_hd_inflate_free(&inflater);
|
||||
}
|
||||
|
@ -452,22 +453,22 @@ void test_nghttp2_hd_inflate_clearall_inc(void) {
|
|||
blocklen = nghttp2_bufs_len(&bufs);
|
||||
|
||||
CU_ASSERT(blocklen > 0);
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0));
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
|
||||
|
||||
CU_ASSERT(1 == out.nvlen);
|
||||
assert_nv_equal(&nv, out.nva, 1);
|
||||
assert_nv_equal(&nv, out.nva, 1, mem);
|
||||
CU_ASSERT(0 == inflater.ctx.hd_table.len);
|
||||
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
|
||||
/* Do it again */
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0));
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
|
||||
|
||||
CU_ASSERT(1 == out.nvlen);
|
||||
assert_nv_equal(&nv, out.nva, 1);
|
||||
assert_nv_equal(&nv, out.nva, 1, mem);
|
||||
CU_ASSERT(0 == inflater.ctx.hd_table.len);
|
||||
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
nghttp2_bufs_reset(&bufs);
|
||||
|
||||
/* This time, 4096 bytes space required, which is just fits in the
|
||||
|
@ -479,13 +480,13 @@ void test_nghttp2_hd_inflate_clearall_inc(void) {
|
|||
blocklen = nghttp2_bufs_len(&bufs);
|
||||
|
||||
CU_ASSERT(blocklen > 0);
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0));
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
|
||||
|
||||
CU_ASSERT(1 == out.nvlen);
|
||||
assert_nv_equal(&nv, out.nva, 1);
|
||||
assert_nv_equal(&nv, out.nva, 1, mem);
|
||||
CU_ASSERT(1 == inflater.ctx.hd_table.len);
|
||||
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
nghttp2_bufs_reset(&bufs);
|
||||
|
||||
nghttp2_bufs_free(&bufs);
|
||||
|
@ -514,7 +515,7 @@ void test_nghttp2_hd_inflate_zero_length_huffman(void) {
|
|||
/* ptr[3] = 0x80; */
|
||||
|
||||
nghttp2_hd_inflate_init(&inflater, mem);
|
||||
CU_ASSERT(4 == inflate_hd(&inflater, &out, &bufs, 0));
|
||||
CU_ASSERT(4 == inflate_hd(&inflater, &out, &bufs, 0, mem));
|
||||
|
||||
CU_ASSERT(1 == out.nvlen);
|
||||
CU_ASSERT(1 == out.nva[0].namelen);
|
||||
|
@ -522,7 +523,7 @@ void test_nghttp2_hd_inflate_zero_length_huffman(void) {
|
|||
CU_ASSERT(NULL == out.nva[0].value);
|
||||
CU_ASSERT(0 == out.nva[0].valuelen);
|
||||
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
nghttp2_bufs_free(&bufs);
|
||||
nghttp2_hd_inflate_free(&inflater);
|
||||
}
|
||||
|
@ -546,7 +547,7 @@ void test_nghttp2_hd_ringbuf_reserve(void) {
|
|||
nv.name = (uint8_t *)"a";
|
||||
nv.namelen = strlen((const char *)nv.name);
|
||||
nv.valuelen = 4;
|
||||
nv.value = malloc(nv.valuelen);
|
||||
nv.value = mem->malloc(nv.valuelen, NULL);
|
||||
memset(nv.value, 0, nv.valuelen);
|
||||
|
||||
nghttp2_hd_deflate_init2(&deflater, 8000, mem);
|
||||
|
@ -563,12 +564,12 @@ void test_nghttp2_hd_ringbuf_reserve(void) {
|
|||
CU_ASSERT(0 == rv);
|
||||
CU_ASSERT(blocklen > 0);
|
||||
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0));
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
|
||||
|
||||
CU_ASSERT(1 == out.nvlen);
|
||||
assert_nv_equal(&nv, out.nva, 1);
|
||||
assert_nv_equal(&nv, out.nva, 1, mem);
|
||||
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
nghttp2_bufs_reset(&bufs);
|
||||
}
|
||||
|
||||
|
@ -576,7 +577,7 @@ void test_nghttp2_hd_ringbuf_reserve(void) {
|
|||
nghttp2_hd_inflate_free(&inflater);
|
||||
nghttp2_hd_deflate_free(&deflater);
|
||||
|
||||
free(nv.value);
|
||||
mem->free(nv.value, NULL);
|
||||
}
|
||||
|
||||
void test_nghttp2_hd_change_table_size(void) {
|
||||
|
@ -616,12 +617,12 @@ void test_nghttp2_hd_change_table_size(void) {
|
|||
CU_ASSERT(2 == deflater.ctx.hd_table.len);
|
||||
CU_ASSERT(4096 == deflater.ctx.hd_table_bufsize_max);
|
||||
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0));
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
|
||||
CU_ASSERT(2 == inflater.ctx.hd_table.len);
|
||||
CU_ASSERT(4096 == inflater.ctx.hd_table_bufsize_max);
|
||||
CU_ASSERT(8000 == inflater.settings_hd_table_bufsize_max);
|
||||
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
nghttp2_bufs_reset(&bufs);
|
||||
|
||||
/* inflater changes header table size to 1024 */
|
||||
|
@ -641,12 +642,12 @@ void test_nghttp2_hd_change_table_size(void) {
|
|||
CU_ASSERT(2 == deflater.ctx.hd_table.len);
|
||||
CU_ASSERT(1024 == deflater.ctx.hd_table_bufsize_max);
|
||||
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0));
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
|
||||
CU_ASSERT(2 == inflater.ctx.hd_table.len);
|
||||
CU_ASSERT(1024 == inflater.ctx.hd_table_bufsize_max);
|
||||
CU_ASSERT(1024 == inflater.settings_hd_table_bufsize_max);
|
||||
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
nghttp2_bufs_reset(&bufs);
|
||||
|
||||
/* inflater changes header table size to 0 */
|
||||
|
@ -668,12 +669,12 @@ void test_nghttp2_hd_change_table_size(void) {
|
|||
CU_ASSERT(0 == deflater.ctx.hd_table.len);
|
||||
CU_ASSERT(0 == deflater.ctx.hd_table_bufsize_max);
|
||||
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0));
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
|
||||
CU_ASSERT(0 == inflater.ctx.hd_table.len);
|
||||
CU_ASSERT(0 == inflater.ctx.hd_table_bufsize_max);
|
||||
CU_ASSERT(0 == inflater.settings_hd_table_bufsize_max);
|
||||
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
nghttp2_bufs_reset(&bufs);
|
||||
|
||||
nghttp2_bufs_free(&bufs);
|
||||
|
@ -703,12 +704,12 @@ void test_nghttp2_hd_change_table_size(void) {
|
|||
CU_ASSERT(2 == deflater.ctx.hd_table.len);
|
||||
CU_ASSERT(8000 == deflater.ctx.hd_table_bufsize_max);
|
||||
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0));
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
|
||||
CU_ASSERT(2 == inflater.ctx.hd_table.len);
|
||||
CU_ASSERT(8000 == inflater.ctx.hd_table_bufsize_max);
|
||||
CU_ASSERT(8000 == inflater.settings_hd_table_bufsize_max);
|
||||
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
nghttp2_bufs_reset(&bufs);
|
||||
|
||||
CU_ASSERT(0 == nghttp2_hd_inflate_change_table_size(&inflater, 16383));
|
||||
|
@ -727,21 +728,22 @@ void test_nghttp2_hd_change_table_size(void) {
|
|||
CU_ASSERT(2 == deflater.ctx.hd_table.len);
|
||||
CU_ASSERT(8192 == deflater.ctx.hd_table_bufsize_max);
|
||||
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0));
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
|
||||
CU_ASSERT(2 == inflater.ctx.hd_table.len);
|
||||
CU_ASSERT(8192 == inflater.ctx.hd_table_bufsize_max);
|
||||
CU_ASSERT(16383 == inflater.settings_hd_table_bufsize_max);
|
||||
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
nghttp2_bufs_reset(&bufs);
|
||||
|
||||
/* Lastly, check the error condition */
|
||||
|
||||
rv = nghttp2_hd_emit_table_size(&bufs, 25600);
|
||||
CU_ASSERT(rv == 0);
|
||||
CU_ASSERT(NGHTTP2_ERR_HEADER_COMP == inflate_hd(&inflater, &out, &bufs, 0));
|
||||
CU_ASSERT(NGHTTP2_ERR_HEADER_COMP ==
|
||||
inflate_hd(&inflater, &out, &bufs, 0, mem));
|
||||
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
nghttp2_bufs_reset(&bufs);
|
||||
|
||||
nghttp2_hd_inflate_free(&inflater);
|
||||
|
@ -763,12 +765,12 @@ void test_nghttp2_hd_change_table_size(void) {
|
|||
CU_ASSERT(2 == deflater.ctx.hd_table.len);
|
||||
CU_ASSERT(1024 == deflater.ctx.hd_table_bufsize_max);
|
||||
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0));
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
|
||||
CU_ASSERT(2 == inflater.ctx.hd_table.len);
|
||||
CU_ASSERT(1024 == inflater.ctx.hd_table_bufsize_max);
|
||||
CU_ASSERT(4096 == inflater.settings_hd_table_bufsize_max);
|
||||
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
nghttp2_bufs_reset(&bufs);
|
||||
|
||||
nghttp2_hd_inflate_free(&inflater);
|
||||
|
@ -787,11 +789,11 @@ void test_nghttp2_hd_change_table_size(void) {
|
|||
CU_ASSERT(0 == rv);
|
||||
CU_ASSERT(UINT32_MAX == deflater.ctx.hd_table_bufsize_max);
|
||||
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0));
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
|
||||
CU_ASSERT(UINT32_MAX == inflater.ctx.hd_table_bufsize_max);
|
||||
CU_ASSERT(UINT32_MAX == inflater.settings_hd_table_bufsize_max);
|
||||
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
nghttp2_bufs_reset(&bufs);
|
||||
|
||||
nghttp2_hd_inflate_free(&inflater);
|
||||
|
@ -817,11 +819,11 @@ void test_nghttp2_hd_change_table_size(void) {
|
|||
CU_ASSERT(3000 == deflater.ctx.hd_table_bufsize_max);
|
||||
CU_ASSERT(UINT32_MAX == deflater.min_hd_table_bufsize_max);
|
||||
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0));
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
|
||||
CU_ASSERT(3000 == inflater.ctx.hd_table_bufsize_max);
|
||||
CU_ASSERT(3000 == inflater.settings_hd_table_bufsize_max);
|
||||
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
nghttp2_bufs_reset(&bufs);
|
||||
|
||||
nghttp2_hd_inflate_free(&inflater);
|
||||
|
@ -832,7 +834,8 @@ void test_nghttp2_hd_change_table_size(void) {
|
|||
|
||||
static void check_deflate_inflate(nghttp2_hd_deflater *deflater,
|
||||
nghttp2_hd_inflater *inflater,
|
||||
nghttp2_nv *nva, size_t nvlen) {
|
||||
nghttp2_nv *nva, size_t nvlen,
|
||||
nghttp2_mem *mem) {
|
||||
nghttp2_bufs bufs;
|
||||
ssize_t blocklen;
|
||||
nva_out out;
|
||||
|
@ -847,12 +850,12 @@ static void check_deflate_inflate(nghttp2_hd_deflater *deflater,
|
|||
CU_ASSERT(0 == rv);
|
||||
CU_ASSERT(blocklen >= 0);
|
||||
|
||||
CU_ASSERT(blocklen == inflate_hd(inflater, &out, &bufs, 0));
|
||||
CU_ASSERT(blocklen == inflate_hd(inflater, &out, &bufs, 0, mem));
|
||||
|
||||
CU_ASSERT(nvlen == out.nvlen);
|
||||
assert_nv_equal(nva, out.nva, nvlen);
|
||||
assert_nv_equal(nva, out.nva, nvlen, mem);
|
||||
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
nghttp2_bufs_free(&bufs);
|
||||
}
|
||||
|
||||
|
@ -999,16 +1002,16 @@ void test_nghttp2_hd_deflate_inflate(void) {
|
|||
nghttp2_hd_deflate_init(&deflater, mem);
|
||||
nghttp2_hd_inflate_init(&inflater, mem);
|
||||
|
||||
check_deflate_inflate(&deflater, &inflater, nv1, ARRLEN(nv1));
|
||||
check_deflate_inflate(&deflater, &inflater, nv2, ARRLEN(nv2));
|
||||
check_deflate_inflate(&deflater, &inflater, nv3, ARRLEN(nv3));
|
||||
check_deflate_inflate(&deflater, &inflater, nv4, ARRLEN(nv4));
|
||||
check_deflate_inflate(&deflater, &inflater, nv5, ARRLEN(nv5));
|
||||
check_deflate_inflate(&deflater, &inflater, nv6, ARRLEN(nv6));
|
||||
check_deflate_inflate(&deflater, &inflater, nv7, ARRLEN(nv7));
|
||||
check_deflate_inflate(&deflater, &inflater, nv8, ARRLEN(nv8));
|
||||
check_deflate_inflate(&deflater, &inflater, nv9, ARRLEN(nv9));
|
||||
check_deflate_inflate(&deflater, &inflater, nv10, ARRLEN(nv10));
|
||||
check_deflate_inflate(&deflater, &inflater, nv1, ARRLEN(nv1), mem);
|
||||
check_deflate_inflate(&deflater, &inflater, nv2, ARRLEN(nv2), mem);
|
||||
check_deflate_inflate(&deflater, &inflater, nv3, ARRLEN(nv3), mem);
|
||||
check_deflate_inflate(&deflater, &inflater, nv4, ARRLEN(nv4), mem);
|
||||
check_deflate_inflate(&deflater, &inflater, nv5, ARRLEN(nv5), mem);
|
||||
check_deflate_inflate(&deflater, &inflater, nv6, ARRLEN(nv6), mem);
|
||||
check_deflate_inflate(&deflater, &inflater, nv7, ARRLEN(nv7), mem);
|
||||
check_deflate_inflate(&deflater, &inflater, nv8, ARRLEN(nv8), mem);
|
||||
check_deflate_inflate(&deflater, &inflater, nv9, ARRLEN(nv9), mem);
|
||||
check_deflate_inflate(&deflater, &inflater, nv10, ARRLEN(nv10), mem);
|
||||
|
||||
nghttp2_hd_inflate_free(&inflater);
|
||||
nghttp2_hd_deflate_free(&deflater);
|
||||
|
@ -1048,17 +1051,17 @@ void test_nghttp2_hd_no_index(void) {
|
|||
|
||||
CU_ASSERT(0 == rv);
|
||||
CU_ASSERT(blocklen > 0);
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0));
|
||||
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
|
||||
|
||||
CU_ASSERT(ARRLEN(nva) == out.nvlen);
|
||||
assert_nv_equal(nva, out.nva, ARRLEN(nva));
|
||||
assert_nv_equal(nva, out.nva, ARRLEN(nva), mem);
|
||||
|
||||
CU_ASSERT(out.nva[0].flags == NGHTTP2_NV_FLAG_NONE);
|
||||
for (i = 1; i < ARRLEN(nva); ++i) {
|
||||
CU_ASSERT(out.nva[i].flags == NGHTTP2_NV_FLAG_NO_INDEX);
|
||||
}
|
||||
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
|
||||
nghttp2_bufs_free(&bufs);
|
||||
nghttp2_hd_inflate_free(&inflater);
|
||||
|
@ -1119,7 +1122,7 @@ void test_nghttp2_hd_public_api(void) {
|
|||
nghttp2_bufs_wrap_init(&bufs, buf, blocklen, mem);
|
||||
bufs.head->buf.last += blocklen;
|
||||
|
||||
CU_ASSERT(blocklen == inflate_hd(inflater, NULL, &bufs, 0));
|
||||
CU_ASSERT(blocklen == inflate_hd(inflater, NULL, &bufs, 0, mem));
|
||||
|
||||
nghttp2_bufs_wrap_free(&bufs);
|
||||
|
||||
|
|
|
@ -145,15 +145,19 @@ void test_nghttp2_map_functional(void) {
|
|||
nghttp2_map_free(&map);
|
||||
}
|
||||
|
||||
static int entry_free(nghttp2_map_entry *entry, void *ptr _U_) {
|
||||
free(entry);
|
||||
static int entry_free(nghttp2_map_entry *entry, void *ptr) {
|
||||
nghttp2_mem *mem = ptr;
|
||||
|
||||
mem->free(entry, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void test_nghttp2_map_each_free(void) {
|
||||
strentry *foo = malloc(sizeof(strentry)), *bar = malloc(sizeof(strentry)),
|
||||
*baz = malloc(sizeof(strentry)),
|
||||
*shrubbery = malloc(sizeof(strentry));
|
||||
nghttp2_mem *mem = nghttp2_mem_default();
|
||||
strentry *foo = mem->malloc(sizeof(strentry), NULL),
|
||||
*bar = mem->malloc(sizeof(strentry), NULL),
|
||||
*baz = mem->malloc(sizeof(strentry), NULL),
|
||||
*shrubbery = mem->malloc(sizeof(strentry), NULL);
|
||||
nghttp2_map map;
|
||||
nghttp2_map_init(&map, nghttp2_mem_default());
|
||||
|
||||
|
@ -167,6 +171,6 @@ void test_nghttp2_map_each_free(void) {
|
|||
nghttp2_map_insert(&map, &baz->map_entry);
|
||||
nghttp2_map_insert(&map, &shrubbery->map_entry);
|
||||
|
||||
nghttp2_map_each_free(&map, entry_free, NULL);
|
||||
nghttp2_map_each_free(&map, entry_free, mem);
|
||||
nghttp2_map_free(&map);
|
||||
}
|
||||
|
|
|
@ -1560,7 +1560,7 @@ void test_nghttp2_session_add_frame(void) {
|
|||
|
||||
CU_ASSERT(0 == nghttp2_session_client_new(&session, &callbacks, &user_data));
|
||||
|
||||
item = malloc(sizeof(nghttp2_outbound_item));
|
||||
item = mem->malloc(sizeof(nghttp2_outbound_item), NULL);
|
||||
|
||||
nghttp2_session_outbound_item_init(session, item);
|
||||
|
||||
|
@ -2474,6 +2474,10 @@ void test_nghttp2_session_on_window_update_received(void) {
|
|||
nghttp2_frame frame;
|
||||
nghttp2_stream *stream;
|
||||
nghttp2_outbound_item *data_item;
|
||||
nghttp2_mem *mem;
|
||||
|
||||
mem = nghttp2_mem_default();
|
||||
|
||||
memset(&callbacks, 0, sizeof(nghttp2_session_callbacks));
|
||||
callbacks.on_frame_recv_callback = on_frame_recv_callback;
|
||||
callbacks.on_invalid_frame_recv_callback = on_invalid_frame_recv_callback;
|
||||
|
@ -2486,7 +2490,7 @@ void test_nghttp2_session_on_window_update_received(void) {
|
|||
&pri_spec_default, NGHTTP2_STREAM_OPENED,
|
||||
NULL);
|
||||
|
||||
data_item = create_data_ob_item();
|
||||
data_item = create_data_ob_item(mem);
|
||||
|
||||
CU_ASSERT(0 == nghttp2_stream_attach_item(stream, data_item, session));
|
||||
|
||||
|
@ -2604,13 +2608,16 @@ void test_nghttp2_session_send_headers_start_stream(void) {
|
|||
nghttp2_outbound_item *item;
|
||||
nghttp2_frame *frame;
|
||||
nghttp2_stream *stream;
|
||||
nghttp2_mem *mem;
|
||||
|
||||
mem = nghttp2_mem_default();
|
||||
|
||||
memset(&callbacks, 0, sizeof(nghttp2_session_callbacks));
|
||||
callbacks.send_callback = null_send_callback;
|
||||
|
||||
nghttp2_session_client_new(&session, &callbacks, NULL);
|
||||
|
||||
item = malloc(sizeof(nghttp2_outbound_item));
|
||||
item = mem->malloc(sizeof(nghttp2_outbound_item), NULL);
|
||||
|
||||
nghttp2_session_outbound_item_init(session, item);
|
||||
|
||||
|
@ -2635,6 +2642,9 @@ void test_nghttp2_session_send_headers_reply(void) {
|
|||
nghttp2_outbound_item *item;
|
||||
nghttp2_frame *frame;
|
||||
nghttp2_stream *stream;
|
||||
nghttp2_mem *mem;
|
||||
|
||||
mem = nghttp2_mem_default();
|
||||
|
||||
memset(&callbacks, 0, sizeof(nghttp2_session_callbacks));
|
||||
callbacks.send_callback = null_send_callback;
|
||||
|
@ -2643,7 +2653,7 @@ void test_nghttp2_session_send_headers_reply(void) {
|
|||
nghttp2_session_open_stream(session, 2, NGHTTP2_STREAM_FLAG_NONE,
|
||||
&pri_spec_default, NGHTTP2_STREAM_OPENING, NULL);
|
||||
|
||||
item = malloc(sizeof(nghttp2_outbound_item));
|
||||
item = mem->malloc(sizeof(nghttp2_outbound_item), NULL);
|
||||
|
||||
nghttp2_session_outbound_item_init(session, item);
|
||||
|
||||
|
@ -2678,7 +2688,7 @@ void test_nghttp2_session_send_headers_frame_size_error(void) {
|
|||
for (i = 0; i < nnv; ++i) {
|
||||
nv[i].name = (uint8_t *)"header";
|
||||
nv[i].namelen = strlen((const char *)nv[i].name);
|
||||
nv[i].value = malloc(vallen + 1);
|
||||
nv[i].value = mem->malloc(vallen + 1, NULL);
|
||||
memset(nv[i].value, '0' + (int)i, vallen);
|
||||
nv[i].value[vallen] = '\0';
|
||||
nv[i].valuelen = vallen;
|
||||
|
@ -2693,7 +2703,7 @@ void test_nghttp2_session_send_headers_frame_size_error(void) {
|
|||
nvlen = nnv;
|
||||
nghttp2_nv_array_copy(&nva, nv, nvlen, mem);
|
||||
|
||||
item = malloc(sizeof(nghttp2_outbound_item));
|
||||
item = mem->malloc(sizeof(nghttp2_outbound_item), NULL);
|
||||
|
||||
nghttp2_session_outbound_item_init(session, item);
|
||||
|
||||
|
@ -2716,7 +2726,7 @@ void test_nghttp2_session_send_headers_frame_size_error(void) {
|
|||
CU_ASSERT(NGHTTP2_ERR_FRAME_SIZE_ERROR == ud.not_sent_error);
|
||||
|
||||
for (i = 0; i < nnv; ++i) {
|
||||
free(nv[i].value);
|
||||
mem->free(nv[i].value, NULL);
|
||||
}
|
||||
nghttp2_session_del(session);
|
||||
}
|
||||
|
@ -2727,6 +2737,9 @@ void test_nghttp2_session_send_headers_push_reply(void) {
|
|||
nghttp2_outbound_item *item;
|
||||
nghttp2_frame *frame;
|
||||
nghttp2_stream *stream;
|
||||
nghttp2_mem *mem;
|
||||
|
||||
mem = nghttp2_mem_default();
|
||||
|
||||
memset(&callbacks, 0, sizeof(nghttp2_session_callbacks));
|
||||
callbacks.send_callback = null_send_callback;
|
||||
|
@ -2735,7 +2748,7 @@ void test_nghttp2_session_send_headers_push_reply(void) {
|
|||
nghttp2_session_open_stream(session, 2, NGHTTP2_STREAM_FLAG_NONE,
|
||||
&pri_spec_default, NGHTTP2_STREAM_RESERVED, NULL);
|
||||
|
||||
item = malloc(sizeof(nghttp2_outbound_item));
|
||||
item = mem->malloc(sizeof(nghttp2_outbound_item), NULL);
|
||||
|
||||
nghttp2_session_outbound_item_init(session, item);
|
||||
|
||||
|
@ -2759,6 +2772,9 @@ void test_nghttp2_session_send_rst_stream(void) {
|
|||
my_user_data user_data;
|
||||
nghttp2_outbound_item *item;
|
||||
nghttp2_frame *frame;
|
||||
nghttp2_mem *mem;
|
||||
|
||||
mem = nghttp2_mem_default();
|
||||
|
||||
memset(&callbacks, 0, sizeof(nghttp2_session_callbacks));
|
||||
callbacks.send_callback = null_send_callback;
|
||||
|
@ -2766,7 +2782,7 @@ void test_nghttp2_session_send_rst_stream(void) {
|
|||
nghttp2_session_open_stream(session, 1, NGHTTP2_STREAM_FLAG_NONE,
|
||||
&pri_spec_default, NGHTTP2_STREAM_OPENING, NULL);
|
||||
|
||||
item = malloc(sizeof(nghttp2_outbound_item));
|
||||
item = mem->malloc(sizeof(nghttp2_outbound_item), NULL);
|
||||
|
||||
nghttp2_session_outbound_item_init(session, item);
|
||||
|
||||
|
@ -2800,7 +2816,7 @@ void test_nghttp2_session_send_push_promise(void) {
|
|||
nghttp2_session_open_stream(session, 1, NGHTTP2_STREAM_FLAG_NONE,
|
||||
&pri_spec_default, NGHTTP2_STREAM_OPENING, NULL);
|
||||
|
||||
item = malloc(sizeof(nghttp2_outbound_item));
|
||||
item = mem->malloc(sizeof(nghttp2_outbound_item), NULL);
|
||||
|
||||
nghttp2_session_outbound_item_init(session, item);
|
||||
|
||||
|
@ -2821,14 +2837,14 @@ void test_nghttp2_session_send_push_promise(void) {
|
|||
/* Received ENABLE_PUSH = 0 */
|
||||
iv.settings_id = NGHTTP2_SETTINGS_ENABLE_PUSH;
|
||||
iv.value = 0;
|
||||
frame = malloc(sizeof(nghttp2_frame));
|
||||
frame = mem->malloc(sizeof(nghttp2_frame), NULL);
|
||||
nghttp2_frame_settings_init(&frame->settings, NGHTTP2_FLAG_NONE,
|
||||
dup_iv(&iv, 1), 1);
|
||||
nghttp2_session_on_settings_received(session, frame, 1);
|
||||
nghttp2_frame_settings_free(&frame->settings, mem);
|
||||
free(frame);
|
||||
mem->free(frame, NULL);
|
||||
|
||||
item = malloc(sizeof(nghttp2_outbound_item));
|
||||
item = mem->malloc(sizeof(nghttp2_outbound_item), NULL);
|
||||
|
||||
nghttp2_session_outbound_item_init(session, item);
|
||||
|
||||
|
@ -2851,7 +2867,7 @@ void test_nghttp2_session_send_push_promise(void) {
|
|||
nghttp2_session_client_new(&session, &callbacks, &ud);
|
||||
nghttp2_session_open_stream(session, 1, NGHTTP2_STREAM_FLAG_NONE,
|
||||
&pri_spec_default, NGHTTP2_STREAM_OPENING, NULL);
|
||||
item = malloc(sizeof(nghttp2_outbound_item));
|
||||
item = mem->malloc(sizeof(nghttp2_outbound_item), NULL);
|
||||
|
||||
nghttp2_session_outbound_item_init(session, item);
|
||||
|
||||
|
@ -3286,6 +3302,9 @@ void test_nghttp2_submit_request_with_data(void) {
|
|||
nghttp2_data_provider data_prd;
|
||||
my_user_data ud;
|
||||
nghttp2_outbound_item *item;
|
||||
nghttp2_mem *mem;
|
||||
|
||||
mem = nghttp2_mem_default();
|
||||
|
||||
memset(&callbacks, 0, sizeof(nghttp2_session_callbacks));
|
||||
callbacks.send_callback = null_send_callback;
|
||||
|
@ -3297,7 +3316,8 @@ void test_nghttp2_submit_request_with_data(void) {
|
|||
&data_prd, NULL));
|
||||
item = nghttp2_session_get_next_ob_item(session);
|
||||
CU_ASSERT(ARRLEN(reqnv) == item->frame.headers.nvlen);
|
||||
assert_nv_equal(reqnv, item->frame.headers.nva, item->frame.headers.nvlen);
|
||||
assert_nv_equal(reqnv, item->frame.headers.nva, item->frame.headers.nvlen,
|
||||
mem);
|
||||
CU_ASSERT(0 == nghttp2_session_send(session));
|
||||
CU_ASSERT(0 == ud.data_source_length);
|
||||
|
||||
|
@ -3332,19 +3352,20 @@ void test_nghttp2_submit_request_without_data(void) {
|
|||
&data_prd, NULL));
|
||||
item = nghttp2_session_get_next_ob_item(session);
|
||||
CU_ASSERT(ARRLEN(reqnv) == item->frame.headers.nvlen);
|
||||
assert_nv_equal(reqnv, item->frame.headers.nva, item->frame.headers.nvlen);
|
||||
assert_nv_equal(reqnv, item->frame.headers.nva, item->frame.headers.nvlen,
|
||||
mem);
|
||||
CU_ASSERT(item->frame.hd.flags & NGHTTP2_FLAG_END_STREAM);
|
||||
|
||||
CU_ASSERT(0 == nghttp2_session_send(session));
|
||||
CU_ASSERT(0 == unpack_frame(&frame, acc.buf, acc.length));
|
||||
|
||||
nghttp2_bufs_add(&bufs, acc.buf, acc.length);
|
||||
inflate_hd(&inflater, &out, &bufs, NGHTTP2_FRAME_HDLEN);
|
||||
inflate_hd(&inflater, &out, &bufs, NGHTTP2_FRAME_HDLEN, mem);
|
||||
|
||||
CU_ASSERT(ARRLEN(reqnv) == out.nvlen);
|
||||
assert_nv_equal(reqnv, out.nva, out.nvlen);
|
||||
assert_nv_equal(reqnv, out.nva, out.nvlen, mem);
|
||||
nghttp2_frame_headers_free(&frame.headers, mem);
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
|
||||
nghttp2_bufs_free(&bufs);
|
||||
nghttp2_hd_inflate_free(&inflater);
|
||||
|
@ -3357,6 +3378,9 @@ void test_nghttp2_submit_response_with_data(void) {
|
|||
nghttp2_data_provider data_prd;
|
||||
my_user_data ud;
|
||||
nghttp2_outbound_item *item;
|
||||
nghttp2_mem *mem;
|
||||
|
||||
mem = nghttp2_mem_default();
|
||||
|
||||
memset(&callbacks, 0, sizeof(nghttp2_session_callbacks));
|
||||
callbacks.send_callback = null_send_callback;
|
||||
|
@ -3370,7 +3394,8 @@ void test_nghttp2_submit_response_with_data(void) {
|
|||
&data_prd));
|
||||
item = nghttp2_session_get_next_ob_item(session);
|
||||
CU_ASSERT(ARRLEN(resnv) == item->frame.headers.nvlen);
|
||||
assert_nv_equal(resnv, item->frame.headers.nva, item->frame.headers.nvlen);
|
||||
assert_nv_equal(resnv, item->frame.headers.nva, item->frame.headers.nvlen,
|
||||
mem);
|
||||
CU_ASSERT(0 == nghttp2_session_send(session));
|
||||
CU_ASSERT(0 == ud.data_source_length);
|
||||
|
||||
|
@ -3407,19 +3432,20 @@ void test_nghttp2_submit_response_without_data(void) {
|
|||
&data_prd));
|
||||
item = nghttp2_session_get_next_ob_item(session);
|
||||
CU_ASSERT(ARRLEN(resnv) == item->frame.headers.nvlen);
|
||||
assert_nv_equal(resnv, item->frame.headers.nva, item->frame.headers.nvlen);
|
||||
assert_nv_equal(resnv, item->frame.headers.nva, item->frame.headers.nvlen,
|
||||
mem);
|
||||
CU_ASSERT(item->frame.hd.flags & NGHTTP2_FLAG_END_STREAM);
|
||||
|
||||
CU_ASSERT(0 == nghttp2_session_send(session));
|
||||
CU_ASSERT(0 == unpack_frame(&frame, acc.buf, acc.length));
|
||||
|
||||
nghttp2_bufs_add(&bufs, acc.buf, acc.length);
|
||||
inflate_hd(&inflater, &out, &bufs, NGHTTP2_FRAME_HDLEN);
|
||||
inflate_hd(&inflater, &out, &bufs, NGHTTP2_FRAME_HDLEN, mem);
|
||||
|
||||
CU_ASSERT(ARRLEN(resnv) == out.nvlen);
|
||||
assert_nv_equal(resnv, out.nva, out.nvlen);
|
||||
assert_nv_equal(resnv, out.nva, out.nvlen, mem);
|
||||
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
nghttp2_bufs_free(&bufs);
|
||||
nghttp2_frame_headers_free(&frame.headers, mem);
|
||||
nghttp2_hd_inflate_free(&inflater);
|
||||
|
@ -3430,6 +3456,9 @@ void test_nghttp2_submit_headers_start_stream(void) {
|
|||
nghttp2_session *session;
|
||||
nghttp2_session_callbacks callbacks;
|
||||
nghttp2_outbound_item *item;
|
||||
nghttp2_mem *mem;
|
||||
|
||||
mem = nghttp2_mem_default();
|
||||
|
||||
memset(&callbacks, 0, sizeof(nghttp2_session_callbacks));
|
||||
CU_ASSERT(0 == nghttp2_session_client_new(&session, &callbacks, NULL));
|
||||
|
@ -3437,7 +3466,8 @@ void test_nghttp2_submit_headers_start_stream(void) {
|
|||
NULL, reqnv, ARRLEN(reqnv), NULL));
|
||||
item = nghttp2_session_get_next_ob_item(session);
|
||||
CU_ASSERT(ARRLEN(reqnv) == item->frame.headers.nvlen);
|
||||
assert_nv_equal(reqnv, item->frame.headers.nva, item->frame.headers.nvlen);
|
||||
assert_nv_equal(reqnv, item->frame.headers.nva, item->frame.headers.nvlen,
|
||||
mem);
|
||||
CU_ASSERT((NGHTTP2_FLAG_END_HEADERS | NGHTTP2_FLAG_END_STREAM) ==
|
||||
item->frame.hd.flags);
|
||||
CU_ASSERT(0 == (item->frame.hd.flags & NGHTTP2_FLAG_PRIORITY));
|
||||
|
@ -3451,6 +3481,9 @@ void test_nghttp2_submit_headers_reply(void) {
|
|||
my_user_data ud;
|
||||
nghttp2_outbound_item *item;
|
||||
nghttp2_stream *stream;
|
||||
nghttp2_mem *mem;
|
||||
|
||||
mem = nghttp2_mem_default();
|
||||
|
||||
memset(&callbacks, 0, sizeof(nghttp2_session_callbacks));
|
||||
callbacks.send_callback = null_send_callback;
|
||||
|
@ -3461,7 +3494,8 @@ void test_nghttp2_submit_headers_reply(void) {
|
|||
NULL, resnv, ARRLEN(resnv), NULL));
|
||||
item = nghttp2_session_get_next_ob_item(session);
|
||||
CU_ASSERT(ARRLEN(resnv) == item->frame.headers.nvlen);
|
||||
assert_nv_equal(resnv, item->frame.headers.nva, item->frame.headers.nvlen);
|
||||
assert_nv_equal(resnv, item->frame.headers.nva, item->frame.headers.nvlen,
|
||||
mem);
|
||||
CU_ASSERT((NGHTTP2_FLAG_END_STREAM | NGHTTP2_FLAG_END_HEADERS) ==
|
||||
item->frame.hd.flags);
|
||||
|
||||
|
@ -3561,7 +3595,8 @@ void test_nghttp2_submit_headers(void) {
|
|||
NULL, reqnv, ARRLEN(reqnv), NULL));
|
||||
item = nghttp2_session_get_next_ob_item(session);
|
||||
CU_ASSERT(ARRLEN(reqnv) == item->frame.headers.nvlen);
|
||||
assert_nv_equal(reqnv, item->frame.headers.nva, item->frame.headers.nvlen);
|
||||
assert_nv_equal(reqnv, item->frame.headers.nva, item->frame.headers.nvlen,
|
||||
mem);
|
||||
CU_ASSERT((NGHTTP2_FLAG_END_STREAM | NGHTTP2_FLAG_END_HEADERS) ==
|
||||
item->frame.hd.flags);
|
||||
|
||||
|
@ -3586,12 +3621,12 @@ void test_nghttp2_submit_headers(void) {
|
|||
CU_ASSERT(0 == unpack_frame(&frame, acc.buf, acc.length));
|
||||
|
||||
nghttp2_bufs_add(&bufs, acc.buf, acc.length);
|
||||
inflate_hd(&inflater, &out, &bufs, NGHTTP2_FRAME_HDLEN);
|
||||
inflate_hd(&inflater, &out, &bufs, NGHTTP2_FRAME_HDLEN, mem);
|
||||
|
||||
CU_ASSERT(ARRLEN(reqnv) == out.nvlen);
|
||||
assert_nv_equal(reqnv, out.nva, out.nvlen);
|
||||
assert_nv_equal(reqnv, out.nva, out.nvlen, mem);
|
||||
|
||||
nva_out_reset(&out);
|
||||
nva_out_reset(&out, mem);
|
||||
nghttp2_bufs_free(&bufs);
|
||||
nghttp2_frame_headers_free(&frame.headers, mem);
|
||||
|
||||
|
@ -4292,12 +4327,12 @@ void test_nghttp2_session_pop_next_ob_item(void) {
|
|||
item = nghttp2_session_pop_next_ob_item(session);
|
||||
CU_ASSERT(NGHTTP2_PING == item->frame.hd.type);
|
||||
nghttp2_outbound_item_free(item, mem);
|
||||
free(item);
|
||||
mem->free(item, NULL);
|
||||
|
||||
item = nghttp2_session_pop_next_ob_item(session);
|
||||
CU_ASSERT(NGHTTP2_HEADERS == item->frame.hd.type);
|
||||
nghttp2_outbound_item_free(item, mem);
|
||||
free(item);
|
||||
mem->free(item, NULL);
|
||||
|
||||
CU_ASSERT(NULL == nghttp2_session_pop_next_ob_item(session));
|
||||
|
||||
|
@ -4323,7 +4358,7 @@ void test_nghttp2_session_pop_next_ob_item(void) {
|
|||
nghttp2_stream_detach_item(stream, session);
|
||||
|
||||
nghttp2_outbound_item_free(item, mem);
|
||||
free(item);
|
||||
mem->free(item, NULL);
|
||||
|
||||
CU_ASSERT(NULL == nghttp2_session_pop_next_ob_item(session));
|
||||
|
||||
|
@ -4332,7 +4367,7 @@ void test_nghttp2_session_pop_next_ob_item(void) {
|
|||
item = nghttp2_session_pop_next_ob_item(session);
|
||||
CU_ASSERT(NGHTTP2_HEADERS == item->frame.hd.type);
|
||||
nghttp2_outbound_item_free(item, mem);
|
||||
free(item);
|
||||
mem->free(item, NULL);
|
||||
|
||||
nghttp2_session_del(session);
|
||||
|
||||
|
@ -5094,7 +5129,8 @@ void test_nghttp2_session_data_backoff_by_high_pri_frame(void) {
|
|||
}
|
||||
|
||||
static void check_session_recv_data_with_padding(nghttp2_bufs *bufs,
|
||||
size_t datalen) {
|
||||
size_t datalen,
|
||||
nghttp2_mem *mem) {
|
||||
nghttp2_session *session;
|
||||
my_user_data ud;
|
||||
nghttp2_session_callbacks callbacks;
|
||||
|
@ -5119,7 +5155,7 @@ static void check_session_recv_data_with_padding(nghttp2_bufs *bufs,
|
|||
CU_ASSERT(1 == ud.frame_recv_cb_called);
|
||||
CU_ASSERT(datalen == ud.data_chunk_len);
|
||||
|
||||
free(in);
|
||||
mem->free(in, NULL);
|
||||
nghttp2_session_del(session);
|
||||
}
|
||||
|
||||
|
@ -5130,6 +5166,9 @@ void test_nghttp2_session_pack_data_with_padding(void) {
|
|||
nghttp2_data_provider data_prd;
|
||||
nghttp2_frame *frame;
|
||||
size_t datalen = 55;
|
||||
nghttp2_mem *mem;
|
||||
|
||||
mem = nghttp2_mem_default();
|
||||
|
||||
memset(&callbacks, 0, sizeof(callbacks));
|
||||
callbacks.send_callback = block_count_send_callback;
|
||||
|
@ -5155,7 +5194,7 @@ void test_nghttp2_session_pack_data_with_padding(void) {
|
|||
CU_ASSERT(frame->hd.flags & NGHTTP2_FLAG_PADDED);
|
||||
|
||||
/* Check reception of this DATA frame */
|
||||
check_session_recv_data_with_padding(&session->aob.framebufs, datalen);
|
||||
check_session_recv_data_with_padding(&session->aob.framebufs, datalen, mem);
|
||||
|
||||
nghttp2_session_del(session);
|
||||
}
|
||||
|
@ -5220,7 +5259,7 @@ void test_nghttp2_pack_settings_payload(void) {
|
|||
CU_ASSERT(NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE == resiv[1].settings_id);
|
||||
CU_ASSERT(4095 == resiv[1].value);
|
||||
|
||||
free(resiv);
|
||||
mem->free(resiv, NULL);
|
||||
|
||||
len = nghttp2_pack_settings_payload(buf, 9 /* too small */, iv, 2);
|
||||
CU_ASSERT(NGHTTP2_ERR_INSUFF_BUFSIZE == len);
|
||||
|
@ -5892,6 +5931,9 @@ void test_nghttp2_session_stream_attach_item(void) {
|
|||
nghttp2_session_callbacks callbacks;
|
||||
nghttp2_stream *a, *b, *c, *d;
|
||||
nghttp2_outbound_item *da, *db, *dc, *dd;
|
||||
nghttp2_mem *mem;
|
||||
|
||||
mem = nghttp2_mem_default();
|
||||
|
||||
memset(&callbacks, 0, sizeof(callbacks));
|
||||
|
||||
|
@ -5909,7 +5951,7 @@ void test_nghttp2_session_stream_attach_item(void) {
|
|||
* d
|
||||
*/
|
||||
|
||||
db = create_data_ob_item();
|
||||
db = create_data_ob_item(mem);
|
||||
|
||||
nghttp2_stream_attach_item(b, db, session);
|
||||
|
||||
|
@ -5924,7 +5966,7 @@ void test_nghttp2_session_stream_attach_item(void) {
|
|||
|
||||
CU_ASSERT(1 == db->queued);
|
||||
|
||||
dc = create_data_ob_item();
|
||||
dc = create_data_ob_item(mem);
|
||||
|
||||
nghttp2_stream_attach_item(c, dc, session);
|
||||
|
||||
|
@ -5940,7 +5982,7 @@ void test_nghttp2_session_stream_attach_item(void) {
|
|||
|
||||
CU_ASSERT(1 == dc->queued);
|
||||
|
||||
da = create_data_ob_item();
|
||||
da = create_data_ob_item(mem);
|
||||
|
||||
nghttp2_stream_attach_item(a, da, session);
|
||||
|
||||
|
@ -5963,7 +6005,7 @@ void test_nghttp2_session_stream_attach_item(void) {
|
|||
CU_ASSERT(16 * 16 / 32 == b->effective_weight);
|
||||
CU_ASSERT(16 * 16 / 32 == c->effective_weight);
|
||||
|
||||
dd = create_data_ob_item();
|
||||
dd = create_data_ob_item(mem);
|
||||
|
||||
nghttp2_stream_attach_item(d, dd, session);
|
||||
|
||||
|
@ -6007,6 +6049,9 @@ void test_nghttp2_session_stream_attach_item_subtree(void) {
|
|||
nghttp2_session_callbacks callbacks;
|
||||
nghttp2_stream *a, *b, *c, *d, *e, *f;
|
||||
nghttp2_outbound_item *db, *dd, *de;
|
||||
nghttp2_mem *mem;
|
||||
|
||||
mem = nghttp2_mem_default();
|
||||
|
||||
memset(&callbacks, 0, sizeof(callbacks));
|
||||
|
||||
|
@ -6027,11 +6072,11 @@ void test_nghttp2_session_stream_attach_item_subtree(void) {
|
|||
* d
|
||||
*/
|
||||
|
||||
de = create_data_ob_item();
|
||||
de = create_data_ob_item(mem);
|
||||
|
||||
nghttp2_stream_attach_item(e, de, session);
|
||||
|
||||
db = create_data_ob_item();
|
||||
db = create_data_ob_item(mem);
|
||||
|
||||
nghttp2_stream_attach_item(b, db, session);
|
||||
|
||||
|
@ -6129,7 +6174,7 @@ void test_nghttp2_session_stream_attach_item_subtree(void) {
|
|||
CU_ASSERT(NGHTTP2_STREAM_DPRI_TOP == e->dpri);
|
||||
CU_ASSERT(NGHTTP2_STREAM_DPRI_NO_ITEM == f->dpri);
|
||||
|
||||
dd = create_data_ob_item();
|
||||
dd = create_data_ob_item(mem);
|
||||
|
||||
nghttp2_stream_attach_item(d, dd, session);
|
||||
|
||||
|
|
|
@ -114,26 +114,26 @@ void nva_out_init(nva_out *out) {
|
|||
out->nvlen = 0;
|
||||
}
|
||||
|
||||
void nva_out_reset(nva_out *out) {
|
||||
void nva_out_reset(nva_out *out, nghttp2_mem *mem) {
|
||||
size_t i;
|
||||
for (i = 0; i < out->nvlen; ++i) {
|
||||
free(out->nva[i].name);
|
||||
free(out->nva[i].value);
|
||||
mem->free(out->nva[i].name, NULL);
|
||||
mem->free(out->nva[i].value, NULL);
|
||||
}
|
||||
memset(out->nva, 0, sizeof(out->nva));
|
||||
out->nvlen = 0;
|
||||
}
|
||||
|
||||
void add_out(nva_out *out, nghttp2_nv *nv) {
|
||||
void add_out(nva_out *out, nghttp2_nv *nv, nghttp2_mem *mem) {
|
||||
nghttp2_nv *onv = &out->nva[out->nvlen];
|
||||
if (nv->namelen) {
|
||||
onv->name = malloc(nv->namelen);
|
||||
onv->name = mem->malloc(nv->namelen, NULL);
|
||||
memcpy(onv->name, nv->name, nv->namelen);
|
||||
} else {
|
||||
onv->name = NULL;
|
||||
}
|
||||
if (nv->valuelen) {
|
||||
onv->value = malloc(nv->valuelen);
|
||||
onv->value = mem->malloc(nv->valuelen, NULL);
|
||||
memcpy(onv->value, nv->value, nv->valuelen);
|
||||
} else {
|
||||
onv->value = NULL;
|
||||
|
@ -147,7 +147,7 @@ void add_out(nva_out *out, nghttp2_nv *nv) {
|
|||
}
|
||||
|
||||
ssize_t inflate_hd(nghttp2_hd_inflater *inflater, nva_out *out,
|
||||
nghttp2_bufs *bufs, size_t offset) {
|
||||
nghttp2_bufs *bufs, size_t offset, nghttp2_mem *mem) {
|
||||
ssize_t rv;
|
||||
nghttp2_nv nv;
|
||||
int inflate_flags;
|
||||
|
@ -186,7 +186,7 @@ ssize_t inflate_hd(nghttp2_hd_inflater *inflater, nva_out *out,
|
|||
|
||||
if (inflate_flags & NGHTTP2_HD_INFLATE_EMIT) {
|
||||
if (out) {
|
||||
add_out(out, &nv);
|
||||
add_out(out, &nv, mem);
|
||||
}
|
||||
}
|
||||
if (inflate_flags & NGHTTP2_HD_INFLATE_FINAL) {
|
||||
|
@ -293,10 +293,10 @@ nghttp2_stream *open_stream_with_dep_excl(nghttp2_session *session,
|
|||
dep_stream);
|
||||
}
|
||||
|
||||
nghttp2_outbound_item *create_data_ob_item(void) {
|
||||
nghttp2_outbound_item *create_data_ob_item(nghttp2_mem *mem) {
|
||||
nghttp2_outbound_item *item;
|
||||
|
||||
item = malloc(sizeof(nghttp2_outbound_item));
|
||||
item = mem->malloc(sizeof(nghttp2_outbound_item), NULL);
|
||||
memset(item, 0, sizeof(nghttp2_outbound_item));
|
||||
|
||||
return item;
|
||||
|
|
|
@ -40,12 +40,12 @@
|
|||
}
|
||||
#define ARRLEN(ARR) (sizeof(ARR) / sizeof(ARR[0]))
|
||||
|
||||
#define assert_nv_equal(A, B, len) \
|
||||
#define assert_nv_equal(A, B, len, mem) \
|
||||
do { \
|
||||
size_t alloclen = sizeof(nghttp2_nv) * len; \
|
||||
const nghttp2_nv *sa = A, *sb = B; \
|
||||
nghttp2_nv *a = malloc(alloclen); \
|
||||
nghttp2_nv *b = malloc(alloclen); \
|
||||
nghttp2_nv *a = mem->malloc(alloclen, NULL); \
|
||||
nghttp2_nv *b = mem->malloc(alloclen, NULL); \
|
||||
ssize_t i_; \
|
||||
memcpy(a, sa, alloclen); \
|
||||
memcpy(b, sb, alloclen); \
|
||||
|
@ -54,8 +54,8 @@
|
|||
for (i_ = 0; i_ < (ssize_t)len; ++i_) { \
|
||||
CU_ASSERT(nghttp2_nv_equal(&a[i_], &b[i_])); \
|
||||
} \
|
||||
free(b); \
|
||||
free(a); \
|
||||
mem->free(b, NULL); \
|
||||
mem->free(a, NULL); \
|
||||
} while (0);
|
||||
|
||||
int unpack_framebuf(nghttp2_frame *frame, nghttp2_bufs *bufs);
|
||||
|
@ -74,12 +74,12 @@ typedef struct {
|
|||
} nva_out;
|
||||
|
||||
void nva_out_init(nva_out *out);
|
||||
void nva_out_reset(nva_out *out);
|
||||
void nva_out_reset(nva_out *out, nghttp2_mem *mem);
|
||||
|
||||
void add_out(nva_out *out, nghttp2_nv *nv);
|
||||
void add_out(nva_out *out, nghttp2_nv *nv, nghttp2_mem *mem);
|
||||
|
||||
ssize_t inflate_hd(nghttp2_hd_inflater *inflater, nva_out *out,
|
||||
nghttp2_bufs *bufs, size_t offset);
|
||||
nghttp2_bufs *bufs, size_t offset, nghttp2_mem *mem);
|
||||
|
||||
int pack_headers(nghttp2_bufs *bufs, nghttp2_hd_deflater *deflater,
|
||||
int32_t stream_id, int flags, const nghttp2_nv *nva,
|
||||
|
@ -107,6 +107,6 @@ nghttp2_stream *open_stream_with_dep_excl(nghttp2_session *session,
|
|||
int32_t stream_id,
|
||||
nghttp2_stream *dep_stream);
|
||||
|
||||
nghttp2_outbound_item *create_data_ob_item(void);
|
||||
nghttp2_outbound_item *create_data_ob_item(nghttp2_mem *mem);
|
||||
|
||||
#endif /* NGHTTP2_TEST_HELPER_H */
|
||||
|
|
Loading…
Reference in New Issue