mirror of
https://github.com/nghttp2/nghttp2.git
synced 2025-12-07 10:38:53 +08:00
tests: Use nghttp2_mem instead of raw malloc()/free()
Fixes GH-170
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user