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

@@ -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);
}