shared/xalloc.h: do not rely on zalloc()

The definition of zalloc is trivial, so let's just have it here instead
of loading libweston/zalloc.h.

Now xalloc.h does not depend on any libweston header, which makes me
feel slightly better. It's more clean.

Who knows, maybe one day libweston/zalloc.h will be removed.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
dev
Pekka Paalanen 2 years ago
parent c95feefbc0
commit fc26c749df
  1. 4
      shared/xalloc.h

@ -36,8 +36,6 @@ extern "C" {
#include <unistd.h> #include <unistd.h>
#include <string.h> #include <string.h>
#include <libweston/zalloc.h>
static inline void * static inline void *
abort_oom_if_null(void *p) abort_oom_if_null(void *p)
{ {
@ -54,7 +52,7 @@ abort_oom_if_null(void *p)
} }
#define xmalloc(s) (abort_oom_if_null(malloc(s))) #define xmalloc(s) (abort_oom_if_null(malloc(s)))
#define xzalloc(s) (abort_oom_if_null(zalloc(s))) #define xzalloc(s) (abort_oom_if_null(calloc(1, s)))
#define xcalloc(n, s) (abort_oom_if_null(calloc(n, s))) #define xcalloc(n, s) (abort_oom_if_null(calloc(n, s)))
#define xstrdup(s) (abort_oom_if_null(strdup(s))) #define xstrdup(s) (abort_oom_if_null(strdup(s)))
#define xrealloc(p, s) (abort_oom_if_null(realloc(p, s))) #define xrealloc(p, s) (abort_oom_if_null(realloc(p, s)))

Loading…
Cancel
Save