diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2014-01-24 21:28:42 -0800 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2014-01-24 21:28:42 -0800 |
commit | 44e30afcdcb8df8bab18feb4f0e6720707d4a0e5 (patch) | |
tree | 3a4c17730826667cb4c3c1d8b5297f2af4409382 /src/shared | |
parent | ae0292eef174778420f286968cfa687c1644216b (diff) | |
download | bluez-44e30afcdcb8df8bab18feb4f0e6720707d4a0e5.tar.gz |
shared: Avoid using GLib allocation functions for tester
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/tester.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/src/shared/tester.c b/src/shared/tester.c index 06fc4158a..eafbfb0f8 100644 --- a/src/shared/tester.c +++ b/src/shared/tester.c @@ -29,11 +29,13 @@ #include <errno.h> #include <unistd.h> #include <stdlib.h> +#include <string.h> #include <signal.h> #include <sys/signalfd.h> #include <glib.h> +#include "src/shared/util.h" #include "src/shared/tester.h" #define COLOR_OFF "\x1B[0m" @@ -114,8 +116,8 @@ static void test_destroy(gpointer data) if (test->destroy) test->destroy(test->user_data); - g_free(test->name); - g_free(test); + free(test->name); + free(test); } void tester_print(const char *format, ...) @@ -190,9 +192,14 @@ void tester_add_full(const char *name, const void *test_data, return; } - test = g_new0(struct test_case, 1); + test = new0(struct test_case, 1); + if (!test) { + if (destroy) + destroy(user_data); + return; + } - test->name = g_strdup(name); + test->name = strdup(name); test->result = TEST_RESULT_NOT_RUN; test->stage = TEST_STAGE_INVALID; @@ -617,7 +624,7 @@ static gboolean wait_callback(gpointer user_data) wait->func(wait->user_data); - g_free(wait); + free(wait); return FALSE; } @@ -636,9 +643,9 @@ void tester_wait(unsigned int seconds, tester_wait_func_t func, test = test_current->data; - print_progress(test->name, COLOR_BLACK, "waiting %u seconds", seconds); - - wait = g_new0(struct wait_data, 1); + wait = new0(struct wait_data, 1); + if (!wait) + return; wait->seconds = seconds; wait->test = test; @@ -646,6 +653,8 @@ void tester_wait(unsigned int seconds, tester_wait_func_t func, wait->user_data = user_data; g_timeout_add(1000, wait_callback, wait); + + print_progress(test->name, COLOR_BLACK, "waiting %u seconds", seconds); } static gboolean signal_handler(GIOChannel *channel, GIOCondition condition, |