aboutsummaryrefslogtreecommitdiff
path: root/test/suites/api
diff options
context:
space:
mode:
authorNathaniel McCallum <npmccallum@redhat.com>2015-12-21 11:46:32 -0500
committerNathaniel McCallum <npmccallum@redhat.com>2015-12-21 11:46:32 -0500
commit245e532934fc9a6df18cf246c29c79863d6ce714 (patch)
tree010021acac3d0883646163d2dad7902acadecaeb /test/suites/api
parente44b2231b50aea5de78b7ea2debec0d5327cd711 (diff)
downloadjansson-245e532934fc9a6df18cf246c29c79863d6ce714.zip
jansson-245e532934fc9a6df18cf246c29c79863d6ce714.tar.gz
jansson-245e532934fc9a6df18cf246c29c79863d6ce714.tar.bz2
Add json_get_alloc_funcs() to allow alloc function fetching
This is particularly useful in modular situations where the allocation functions are either unknown or private. For instance, in such cases, the caller of json_dumps() has no way to free the returned buffer.
Diffstat (limited to 'test/suites/api')
-rw-r--r--test/suites/api/test_memory_funcs.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/test/suites/api/test_memory_funcs.c b/test/suites/api/test_memory_funcs.c
index a760c08..047ca67 100644
--- a/test/suites/api/test_memory_funcs.c
+++ b/test/suites/api/test_memory_funcs.c
@@ -36,10 +36,15 @@ static void my_free(void *ptr)
static void test_simple()
{
+ json_malloc_t mfunc = NULL;
+ json_free_t ffunc = NULL;
+
json_set_alloc_funcs(my_malloc, my_free);
+ json_get_alloc_funcs(&mfunc, &ffunc);
create_and_free_complex_object();
- if(malloc_called != 1 || free_called != 1)
+ if (malloc_called != 1 || free_called != 1
+ || mfunc != my_malloc || ffunc != my_free)
fail("Custom allocation failed");
}