Commit 9af02749 authored by Chad Versace's avatar Chad Versace

all: Kill duplicate allocation error handling code

Replace blocks like this:
    x = calloc(1, sizeof(*x));
    if (x == NULL) {
        wcore_error(WAFFLE_OUT_OF_MEMORY);
        return NULL;
    }

with:
    x = wcore_calloc(sizeof(*x));
    if (x == NULL)
        return NULL;
Signed-off-by: default avatarChad Versace <chad.versace@linux.intel.com>
parent ba4d13f8
......@@ -124,11 +124,9 @@ glx_config_choose(struct wcore_platform *wc_plat,
if (!glx_config_check_context_attrs(dpy, attrs))
return NULL;
self = calloc(1, sizeof(*self));
if (!self) {
wcore_error(WAFFLE_OUT_OF_MEMORY);
self = wcore_calloc(sizeof(*self));
if (self == NULL)
return NULL;
}
ok = wcore_config_init(&self->wcore, wc_dpy);
if (!ok)
......
......@@ -162,11 +162,9 @@ glx_context_create(struct wcore_platform *wc_plat,
struct glx_context *share_ctx = glx_context(wc_share_ctx);
bool ok = true;
self = calloc(1, sizeof(*self));
if (!self) {
wcore_error(WAFFLE_OUT_OF_MEMORY);
self = wcore_calloc(sizeof(*self));
if (self == NULL)
return NULL;
}
ok = wcore_context_init(&self->wcore, wc_config);
if (!ok)
......
......@@ -77,11 +77,9 @@ glx_display_connect(struct wcore_platform *wc_plat,
struct glx_display *self;
bool ok = true;
self = calloc(1, sizeof(*self));
if (!self) {
wcore_error(WAFFLE_OUT_OF_MEMORY);
self = wcore_calloc(sizeof(*self));
if (self == NULL)
return NULL;
}
ok = wcore_display_init(&self->wcore, wc_plat);
if (!ok)
......
......@@ -59,11 +59,9 @@ glx_platform_create(void)
struct glx_platform *self;
bool ok = true;
self= calloc(1, sizeof(*self));
if (!self) {
wcore_error(WAFFLE_OUT_OF_MEMORY);
self = wcore_calloc(sizeof(*self));
if (self == NULL)
return NULL;
}
ok = wcore_platform_init(&self->wcore);
if (!ok)
......
......@@ -64,11 +64,9 @@ glx_window_create(struct wcore_platform *wc_plat,
struct glx_config *config = glx_config(wc_config);
bool ok = true;
self = calloc(1, sizeof(*self));
if (!self) {
wcore_error(WAFFLE_OUT_OF_MEMORY);
self = wcore_calloc(sizeof(*self));
if (self == NULL)
return NULL;
}
ok = wcore_window_init(&self->wcore, wc_config);
if (!ok)
......
......@@ -37,6 +37,7 @@
#include <waffle/waffle_enum.h>
#include <waffle/core/wcore_error.h>
#include <waffle/core/wcore_util.h>
struct linux_dl {
/// @brief For example, "libGLESv2.so".
......@@ -64,11 +65,9 @@ linux_dl_get_name(int32_t waffle_dl)
struct linux_dl*
linux_dl_open(int32_t waffle_dl)
{
struct linux_dl *self = calloc(1, sizeof(*self));
if (!self) {
wcore_error(WAFFLE_OUT_OF_MEMORY);
struct linux_dl *self = wcore_calloc(sizeof(*self));
if (self == NULL)
return NULL;
}
self->name = linux_dl_get_name(waffle_dl);
if (!self->name)
......
......@@ -34,6 +34,7 @@
#include <waffle/waffle_enum.h>
#include <waffle/core/wcore_error.h>
#include <waffle/core/wcore_util.h>
#include "linux_dl.h"
......@@ -46,13 +47,7 @@ struct linux_platform {
struct linux_platform*
linux_platform_create(void)
{
struct linux_platform *self = calloc(1, sizeof(*self));
if (!self) {
wcore_error(WAFFLE_OUT_OF_MEMORY);
return NULL;
}
return self;
return wcore_calloc(sizeof(struct linux_platform));
}
bool
......
......@@ -61,11 +61,9 @@ wayland_config_choose(struct wcore_platform *wc_plat,
struct wayland_display *dpy = wayland_display(wc_dpy);
bool ok = true;
self = calloc(1, sizeof(*self));
if (!self) {
wcore_error(WAFFLE_OUT_OF_MEMORY);
self = wcore_calloc(sizeof(*self));
if (self == NULL)
return NULL;
}
ok = wcore_config_init(&self->wcore, wc_dpy);
if (!ok)
......
......@@ -66,11 +66,9 @@ wayland_context_create(struct wcore_platform *wc_plat,
struct wayland_display *dpy = wayland_display(wc_config->display);
bool ok = true;
self = calloc(1, sizeof(*self));
if (!self) {
wcore_error(WAFFLE_OUT_OF_MEMORY);
self = wcore_calloc(sizeof(*self));
if (self == NULL)
return NULL;
}
ok = wcore_context_init(&self->wcore, wc_config);
if (!ok)
......
......@@ -84,11 +84,9 @@ wayland_display_connect(struct wcore_platform *wc_plat,
struct wayland_display *self;
bool ok = true;
self = calloc(1, sizeof(*self));
if (!self) {
wcore_error(WAFFLE_OUT_OF_MEMORY);
self = wcore_calloc(sizeof(*self));
if (self == NULL)
return NULL;
}
ok = wcore_display_init(&self->wcore, wc_plat);
if (!ok)
......
......@@ -65,11 +65,9 @@ wayland_platform_create(void)
struct wayland_platform *self;
bool ok = true;
self= calloc(1, sizeof(*self));
if (!self) {
wcore_error(WAFFLE_OUT_OF_MEMORY);
self = wcore_calloc(sizeof(*self));
if (self == NULL)
return NULL;
}
ok = wcore_platform_init(&self->wcore);
if (!ok)
......
......@@ -80,11 +80,9 @@ wayland_window_create(struct wcore_platform *wc_plat,
struct wayland_display *dpy = wayland_display(wc_config->display);
bool ok = true;
self = calloc(1, sizeof(*self));
if (!self) {
wcore_error(WAFFLE_OUT_OF_MEMORY);
self = wcore_calloc(sizeof(*self));
if (self == NULL)
return NULL;
}
ok = wcore_window_init(&self->wcore, wc_config);
if (!ok)
......
......@@ -59,11 +59,9 @@ xegl_config_choose(struct wcore_platform *wc_plat,
struct xegl_display *dpy = xegl_display(wc_dpy);
bool ok = true;
self = calloc(1, sizeof(*self));
if (!self) {
wcore_error(WAFFLE_OUT_OF_MEMORY);
self = wcore_calloc(sizeof(*self));
if (self == NULL)
return NULL;
}
ok = wcore_config_init(&self->wcore, wc_dpy);
if (!ok)
......
......@@ -64,11 +64,9 @@ xegl_context_create(struct wcore_platform *wc_plat,
struct xegl_display *dpy = xegl_display(wc_config->display);
bool ok = true;
self = calloc(1, sizeof(*self));
if (!self) {
wcore_error(WAFFLE_OUT_OF_MEMORY);
self = wcore_calloc(sizeof(*self));
if (self == NULL)
return NULL;
}
ok = wcore_context_init(&self->wcore, wc_config);
if (!ok)
......
......@@ -60,11 +60,9 @@ xegl_display_connect(
struct xegl_display *self;
bool ok = true;
self = calloc(1, sizeof(*self));
if (!self) {
wcore_error(WAFFLE_OUT_OF_MEMORY);
self = wcore_calloc(sizeof(*self));
if (self == NULL)
return NULL;
}
ok = wcore_display_init(&self->wcore, wc_plat);
if (!ok)
......
......@@ -64,11 +64,9 @@ xegl_platform_create(void)
struct xegl_platform *self;
bool ok = true;
self= calloc(1, sizeof(*self));
if (!self) {
wcore_error(WAFFLE_OUT_OF_MEMORY);
self = wcore_calloc(sizeof(*self));
if (self == NULL)
return NULL;
}
ok = wcore_platform_init(&self->wcore);
if (!ok)
......
......@@ -67,11 +67,9 @@ xegl_window_create(struct wcore_platform *wc_plat,
struct xegl_display *dpy = xegl_display(wc_config->display);
bool ok = true;
self = calloc(1, sizeof(*self));
if (!self) {
wcore_error(WAFFLE_OUT_OF_MEMORY);
self = wcore_calloc(sizeof(*self));
if (self == NULL)
return NULL;
}
ok = wcore_window_init(&self->wcore, wc_config);
if (!ok)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment