[waffle] [PATCH 01/33] cgl: use wcore_calloc helper

Emil Velikov emil.l.velikov at gmail.com
Mon Jul 7 10:28:08 PDT 2014


Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
---
 src/waffle/cgl/cgl_config.m   | 6 ++----
 src/waffle/cgl/cgl_context.m  | 6 ++----
 src/waffle/cgl/cgl_display.m  | 6 ++----
 src/waffle/cgl/cgl_platform.m | 6 ++----
 src/waffle/cgl/cgl_window.m   | 6 ++----
 5 files changed, 10 insertions(+), 20 deletions(-)

diff --git a/src/waffle/cgl/cgl_config.m b/src/waffle/cgl/cgl_config.m
index 094178b..7a74438 100644
--- a/src/waffle/cgl/cgl_config.m
+++ b/src/waffle/cgl/cgl_config.m
@@ -236,11 +236,9 @@ cgl_config_choose(struct wcore_platform *wc_plat,
     if (!cgl_config_check_attrs(plat, attrs))
         return NULL;
 
-    self = calloc(1, sizeof(*self));
-    if (!self) {
-        wcore_error(WAFFLE_ERROR_BAD_ALLOC);
+    self = wcore_calloc(sizeof(*self));
+    if (!self)
         return NULL;
-    }
 
     ok = wcore_config_init(&self->wcore, wc_dpy, attrs);
     if (!ok)
diff --git a/src/waffle/cgl/cgl_context.m b/src/waffle/cgl/cgl_context.m
index 37c5148..7786113 100644
--- a/src/waffle/cgl/cgl_context.m
+++ b/src/waffle/cgl/cgl_context.m
@@ -61,11 +61,9 @@ cgl_context_create(struct wcore_platform *wc_plat,
 
     int error = 0;
 
-    self = calloc(1, sizeof(*self));
-    if (!self) {
-        wcore_error(WAFFLE_ERROR_BAD_ALLOC);
+    self = wcore_calloc(sizeof(*self));
+    if (!self)
         return NULL;
-    }
 
     error = !wcore_context_init(&self->wcore, wc_config);
     if (error)
diff --git a/src/waffle/cgl/cgl_display.m b/src/waffle/cgl/cgl_display.m
index bafbb28..015ca32 100644
--- a/src/waffle/cgl/cgl_display.m
+++ b/src/waffle/cgl/cgl_display.m
@@ -52,11 +52,9 @@ cgl_display_connect(struct wcore_platform *wc_plat,
     struct cgl_display *self;
     bool ok = true;
 
-    self = calloc(1, sizeof(*self));
-    if (!self) {
-        wcore_error(WAFFLE_ERROR_BAD_ALLOC);
+    self = wcore_calloc(sizeof(*self));
+    if (!self)
         return NULL;
-    }
 
     ok = wcore_display_init(&self->wcore, wc_plat);
     if (!ok)
diff --git a/src/waffle/cgl/cgl_platform.m b/src/waffle/cgl/cgl_platform.m
index fa82041..2da0b40 100644
--- a/src/waffle/cgl/cgl_platform.m
+++ b/src/waffle/cgl/cgl_platform.m
@@ -96,11 +96,9 @@ cgl_platform_create(void)
     struct cgl_platform *self;
     bool ok = true;
 
-    self= calloc(1, sizeof(*self));
-    if (!self) {
-        wcore_error(WAFFLE_ERROR_BAD_ALLOC);
+    self = wcore_calloc(sizeof(*self));
+    if (!self)
         return NULL;
-    }
 
     ok = wcore_platform_init(&self->wcore);
     if (!ok)
diff --git a/src/waffle/cgl/cgl_window.m b/src/waffle/cgl/cgl_window.m
index 1c97590..e4711e1 100644
--- a/src/waffle/cgl/cgl_window.m
+++ b/src/waffle/cgl/cgl_window.m
@@ -100,11 +100,9 @@ cgl_window_create(struct wcore_platform *wc_plat,
     struct cgl_window *self;
     bool ok = true;
 
-    self = calloc(1, sizeof(*self));
-    if (!self) {
-        wcore_error(WAFFLE_ERROR_BAD_ALLOC);
+    self = wcore_calloc(sizeof(*self));
+    if (!self)
         return NULL;
-    }
 
     ok = wcore_window_init(&self->wcore, wc_config);
     if (!ok)
-- 
2.0.0



More information about the waffle mailing list