diff options
author | Lars Wirzenius <liw@liw.fi> | 2010-10-20 20:37:20 +0100 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2010-10-20 20:37:20 +0100 |
commit | e471d201ee5b2423eb6cb4855b7b7c8ff0483119 (patch) | |
tree | 03bf7157a19ed18ee465c2b310bb566ab1a12fc4 | |
parent | bb7232044cfc09a51b899ab73d9df6d076d130fc (diff) | |
download | dynstr-e471d201ee5b2423eb6cb4855b7b7c8ff0483119.tar.gz |
Implement dynstr_set_malloc_error_handler.
-rw-r--r-- | dynstr.c | 9 | ||||
-rw-r--r-- | unittests.c | 10 |
2 files changed, 19 insertions, 0 deletions
@@ -23,6 +23,15 @@ dynstr_error_handler *dynstr_get_malloc_error_handler(void) return error_handler; } +void dynstr_set_malloc_error_handler(dynstr_error_handler *handler) +{ + error_handler = handler; +} + void dynstr_malloc_error_indicate(int error, size_t size, void *oldptr) { } + +void dynstr_malloc_error_abort(int error, size_t size, void *oldptr) +{ +} diff --git a/unittests.c b/unittests.c index 0f43982..fd30081 100644 --- a/unittests.c +++ b/unittests.c @@ -22,6 +22,15 @@ static int test_default_error_handler_is_indicate(void) } +static int test_sets_error_handler(void) +{ + dynstr_set_malloc_error_handler(dynstr_malloc_error_abort); + FAIL_UNLESS_EQUAL(dynstr_get_malloc_error_handler(), + dynstr_malloc_error_abort); + return true; +} + + struct test { const char *name; int (*test)(void); @@ -32,6 +41,7 @@ struct test { static const struct test tests[] = { TEST(test_default_error_handler_is_indicate), + TEST(test_sets_error_handler), }; static const int num_tests = sizeof(tests) / sizeof(tests[0]); |