mirror of
https://gitlab.freedesktop.org/wayland/weston
synced 2024-07-24 04:04:14 +00:00
tests: Add an xmalloc helper function
Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-By: Derek Foreman <derekf@osg.samsung.com>
This commit is contained in:
parent
c1a1d6cecf
commit
61a6436ae0
|
@ -32,6 +32,17 @@
|
||||||
#include "../shared/os-compatibility.h"
|
#include "../shared/os-compatibility.h"
|
||||||
#include "weston-test-client-helper.h"
|
#include "weston-test-client-helper.h"
|
||||||
|
|
||||||
|
void *
|
||||||
|
fail_on_null(void *p)
|
||||||
|
{
|
||||||
|
if (p == NULL) {
|
||||||
|
fprintf(stderr, "out of memory\n");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
surface_contains(struct surface *surface, int x, int y)
|
surface_contains(struct surface *surface, int x, int y)
|
||||||
{
|
{
|
||||||
|
|
|
@ -132,15 +132,19 @@ struct surface {
|
||||||
void *data;
|
void *data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void *
|
||||||
|
fail_on_null(void *p);
|
||||||
|
|
||||||
static inline void *
|
static inline void *
|
||||||
xzalloc(size_t size)
|
xzalloc(size_t s)
|
||||||
{
|
{
|
||||||
void *p;
|
return fail_on_null(calloc(1, s));
|
||||||
|
}
|
||||||
|
|
||||||
p = calloc(1, size);
|
static inline void *
|
||||||
assert(p);
|
xmalloc(size_t s)
|
||||||
|
{
|
||||||
return p;
|
return fail_on_null(malloc(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
struct client *
|
struct client *
|
||||||
|
|
Loading…
Reference in a new issue