tests: Use nghttp2_mem instead of raw malloc()/free()

Fixes GH-170
This commit is contained in:
Tatsuhiro Tsujikawa
2015-03-03 23:23:43 +09:00
parent 291c27c940
commit a2a9f15307
8 changed files with 239 additions and 183 deletions

View File

@@ -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 */