diff options
author | Bryce Harrington <bryce@osg.samsung.com> | 2016-03-16 14:15:18 -0700 |
---|---|---|
committer | Pekka Paalanen <pekka.paalanen@collabora.co.uk> | 2016-03-17 14:13:13 +0200 |
commit | e99e4bf2b9aa13baae46f2a49ff9c9ed8ca631c7 (patch) | |
tree | 7a729aad4350c02a7b82f8ed7ae145d290f5a93b /tests | |
parent | 4e221f0327cbc342d78916a62ace64368471d55b (diff) | |
download | weston-e99e4bf2b9aa13baae46f2a49ff9c9ed8ca631c7.tar.gz |
clients & tests: Unify multiple definitions of x*alloc and related functions
Direct fail_on_null calls now produce output like:
[weston-info] clients/weston-info.c:714: out of memory
xmalloc, et al produce output on failure like:
[weston-info] out of memory (-1)
Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/ivi_layout-test.c | 1 | ||||
-rw-r--r-- | tests/presentation-test.c | 1 | ||||
-rw-r--r-- | tests/weston-test-client-helper.c | 14 | ||||
-rw-r--r-- | tests/weston-test-client-helper.h | 15 |
4 files changed, 4 insertions, 27 deletions
diff --git a/tests/ivi_layout-test.c b/tests/ivi_layout-test.c index e2ee5c44..b775abe3 100644 --- a/tests/ivi_layout-test.c +++ b/tests/ivi_layout-test.c @@ -29,6 +29,7 @@ #include <string.h> #include "shared/helpers.h" +#include "shared/xalloc.h" #include "weston-test-client-helper.h" #include "ivi-application-client-protocol.h" #include "ivi-test.h" diff --git a/tests/presentation-test.c b/tests/presentation-test.c index a985c064..f8c3be56 100644 --- a/tests/presentation-test.c +++ b/tests/presentation-test.c @@ -32,6 +32,7 @@ #include <time.h> #include "shared/helpers.h" +#include "shared/xalloc.h" #include "weston-test-client-helper.h" #include "presentation-time-client-protocol.h" diff --git a/tests/weston-test-client-helper.c b/tests/weston-test-client-helper.c index 97c4395a..3f7ff2b9 100644 --- a/tests/weston-test-client-helper.c +++ b/tests/weston-test-client-helper.c @@ -33,25 +33,15 @@ #include <sys/mman.h> #include <cairo.h> -#include "zalloc.h" #include "shared/os-compatibility.h" +#include "shared/xalloc.h" +#include "shared/zalloc.h" #include "weston-test-client-helper.h" #define max(a, b) (((a) > (b)) ? (a) : (b)) #define min(a, b) (((a) > (b)) ? (b) : (a)) #define clip(x, a, b) min(max(x, a), b) -void * -fail_on_null(void *p) -{ - if (p == NULL) { - fprintf(stderr, "out of memory\n"); - exit(EXIT_FAILURE); - } - return p; -} - - int surface_contains(struct surface *surface, int x, int y) { diff --git a/tests/weston-test-client-helper.h b/tests/weston-test-client-helper.h index e3ebd1f2..51ec8810 100644 --- a/tests/weston-test-client-helper.h +++ b/tests/weston-test-client-helper.h @@ -145,21 +145,6 @@ struct rectangle { int height; }; -void * -fail_on_null(void *p); - -static inline void * -xzalloc(size_t s) -{ - return fail_on_null(calloc(1, s)); -} - -static inline void * -xmalloc(size_t s) -{ - return fail_on_null(malloc(s)); -} - struct client * create_client(void); |