diff options
author | Nathaniel McCallum <npmccallum@redhat.com> | 2015-12-21 11:46:32 -0500 |
---|---|---|
committer | Nathaniel McCallum <npmccallum@redhat.com> | 2015-12-21 11:46:32 -0500 |
commit | 245e532934fc9a6df18cf246c29c79863d6ce714 (patch) | |
tree | 010021acac3d0883646163d2dad7902acadecaeb /test | |
parent | e44b2231b50aea5de78b7ea2debec0d5327cd711 (diff) | |
download | jansson-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')
-rw-r--r-- | test/suites/api/test_memory_funcs.c | 7 |
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"); } |