clients: Use zalloc
authorBryce Harrington <bryce@osg.samsung.com>
Fri, 12 Feb 2016 00:42:49 +0000 (16:42 -0800)
committerBryce Harrington <bryce@osg.samsung.com>
Thu, 10 Mar 2016 06:54:54 +0000 (22:54 -0800)
Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
12 files changed:
clients/desktop-shell.c
clients/fullscreen.c
clients/ivi-shell-user-interface.c
clients/multi-resource.c
clients/presentation-shm.c
clients/simple-damage.c
clients/simple-dmabuf-intel.c
clients/simple-dmabuf-v4l.c
clients/simple-shm.c
clients/subsurfaces.c
clients/weston-info.c
clients/window.c

index 6ab76dc..49a3077 100644 (file)
@@ -46,6 +46,7 @@
 #include "shared/cairo-util.h"
 #include "shared/config-parser.h"
 #include "shared/helpers.h"
+#include "shared/zalloc.h"
 
 #include "weston-desktop-shell-client-protocol.h"
 
@@ -1203,7 +1204,7 @@ create_output(struct desktop *desktop, uint32_t id)
 {
        struct output *output;
 
-       output = calloc(1, sizeof *output);
+       output = zalloc(sizeof *output);
        if (!output)
                return;
 
index 653372a..e2e6477 100644 (file)
@@ -36,6 +36,7 @@
 #include <wayland-client.h>
 #include "window.h"
 #include "fullscreen-shell-unstable-v1-client-protocol.h"
+#include "shared/zalloc.h"
 
 struct fs_output {
        struct wl_list link;
@@ -460,7 +461,11 @@ output_handler(struct output *output, void *data)
                if (fsout->output == output)
                        return;
 
-       fsout = calloc(1, sizeof *fsout);
+       fsout = zalloc(sizeof *fsout);
+       if (fsout == NULL) {
+               fprintf(stderr, "out of memory in output_handler\n");
+               return;
+       }
        fsout->output = output;
        wl_list_insert(&fullscreen->output_list, &fsout->link);
 }
index 2e0622b..1349c73 100644 (file)
@@ -40,6 +40,7 @@
 #include "shared/config-parser.h"
 #include "shared/helpers.h"
 #include "shared/os-compatibility.h"
+#include "shared/zalloc.h"
 #include "ivi-application-client-protocol.h"
 #include "ivi-hmi-controller-client-protocol.h"
 
@@ -177,7 +178,7 @@ fail_on_null(void *p, size_t size, char *file, int32_t line)
 static void *
 mem_alloc(size_t size, char *file, int32_t line)
 {
-       return fail_on_null(calloc(1, size), size, file, line);
+       return fail_on_null(zalloc(size), size, file, line);
 }
 
 #define MEM_ALLOC(s) mem_alloc((s),__FILE__,__LINE__)
index c30d38a..4ed4d50 100644 (file)
@@ -40,6 +40,7 @@
 
 #include <wayland-client.h>
 #include "shared/os-compatibility.h"
+#include "shared/zalloc.h"
 
 struct device {
        enum { KEYBOARD, POINTER } type;
@@ -87,7 +88,7 @@ xzalloc(size_t s)
 {
        void *p;
 
-       p = calloc(1, s);
+       p = zalloc(s);
        if (p == NULL) {
                fprintf(stderr, "%s: out of memory\n", program_invocation_short_name);
                exit(EXIT_FAILURE);
index 1feeb36..2d9b885 100644 (file)
@@ -37,6 +37,7 @@
 
 #include <wayland-client.h>
 #include "shared/helpers.h"
+#include "shared/zalloc.h"
 #include "shared/os-compatibility.h"
 #include "presentation-time-client-protocol.h"
 
@@ -212,7 +213,7 @@ create_window(struct display *display, int width, int height,
                 "presentation-shm: %s [Delay %i msecs]", run_mode_name[mode],
                 commit_delay_msecs);
 
-       window = calloc(1, sizeof *window);
+       window = zalloc(sizeof *window);
        if (!window)
                return NULL;
 
@@ -500,7 +501,7 @@ window_create_feedback(struct window *window, uint32_t frame_stamp)
        if (!pres)
                return;
 
-       feedback = calloc(1, sizeof *feedback);
+       feedback = zalloc(sizeof *feedback);
        if (!feedback)
                return;
 
@@ -678,7 +679,7 @@ display_add_output(struct display *d, uint32_t name, uint32_t version)
 {
        struct output *o;
 
-       o = calloc(1, sizeof(*o));
+       o = zalloc(sizeof(*o));
        assert(o);
 
        o->output = wl_registry_bind(d->registry, name,
index 0353ccc..321b90f 100644 (file)
@@ -37,6 +37,7 @@
 
 #include <wayland-client.h>
 #include "shared/os-compatibility.h"
+#include "shared/zalloc.h"
 #include "xdg-shell-unstable-v5-client-protocol.h"
 #include "fullscreen-shell-unstable-v1-client-protocol.h"
 #include "scaler-client-protocol.h"
@@ -271,7 +272,7 @@ create_window(struct display *display, int width, int height,
                exit(1);
        }
 
-       window = calloc(1, sizeof *window);
+       window = zalloc(sizeof *window);
        if (!window)
                return NULL;
 
index 0ceefeb..2ac2200 100644 (file)
@@ -40,6 +40,7 @@
 #include <drm_fourcc.h>
 
 #include <wayland-client.h>
+#include "shared/zalloc.h"
 #include "xdg-shell-unstable-v5-client-protocol.h"
 #include "fullscreen-shell-unstable-v1-client-protocol.h"
 #include "linux-dmabuf-unstable-v1-client-protocol.h"
@@ -310,7 +311,7 @@ create_window(struct display *display, int width, int height)
        int i;
        int ret;
 
-       window = calloc(1, sizeof *window);
+       window = zalloc(sizeof *window);
        if (!window)
                return NULL;
 
index 29e41ac..a73556c 100644 (file)
@@ -42,6 +42,7 @@
 #include <linux/input.h>
 
 #include <wayland-client.h>
+#include "shared/zalloc.h"
 #include "xdg-shell-unstable-v5-client-protocol.h"
 #include "fullscreen-shell-unstable-v1-client-protocol.h"
 #include "linux-dmabuf-unstable-v1-client-protocol.h"
@@ -544,7 +545,7 @@ create_window(struct display *display)
 {
        struct window *window;
 
-       window = calloc(1, sizeof *window);
+       window = zalloc(sizeof *window);
        if (!window)
                return NULL;
 
index e6f0bd0..6d8f608 100644 (file)
@@ -35,6 +35,7 @@
 
 #include <wayland-client.h>
 #include "shared/os-compatibility.h"
+#include "shared/zalloc.h"
 #include "xdg-shell-unstable-v5-client-protocol.h"
 #include "fullscreen-shell-unstable-v1-client-protocol.h"
 
@@ -157,7 +158,7 @@ create_window(struct display *display, int width, int height)
 {
        struct window *window;
 
-       window = calloc(1, sizeof *window);
+       window = zalloc(sizeof *window);
        if (!window)
                return NULL;
 
index b971fdf..bf0b96b 100644 (file)
@@ -42,6 +42,7 @@
 #include <EGL/eglext.h>
 
 #include "shared/helpers.h"
+#include "shared/zalloc.h"
 #include "window.h"
 
 #if 0
@@ -215,7 +216,7 @@ egl_state_create(struct wl_display *display)
        EGLint major, minor, n;
        EGLBoolean ret;
 
-       egl = calloc(1, sizeof *egl);
+       egl = zalloc(sizeof *egl);
        assert(egl);
 
        egl->dpy =
index 9d42599..e277f88 100644 (file)
@@ -34,6 +34,7 @@
 
 #include "shared/helpers.h"
 #include "shared/os-compatibility.h"
+#include "shared/zalloc.h"
 #include "presentation-time-client-protocol.h"
 
 typedef void (*print_info_t)(void *info);
@@ -138,7 +139,7 @@ xmalloc(size_t s)
 static void *
 xzalloc(size_t s)
 {
-       return fail_on_null(calloc(1, s));
+       return fail_on_null(zalloc(s));
 }
 
 static char *
index 35261b6..ced867e 100644 (file)
@@ -68,6 +68,7 @@ typedef void *EGLContext;
 #include <wayland-client.h>
 #include "shared/cairo-util.h"
 #include "shared/helpers.h"
+#include "shared/zalloc.h"
 #include "xdg-shell-unstable-v5-client-protocol.h"
 #include "text-cursor-position-client-protocol.h"
 #include "shared/os-compatibility.h"
@@ -629,7 +630,7 @@ egl_window_surface_create(struct display *display,
        if (display->dpy == EGL_NO_DISPLAY)
                return NULL;
 
-       surface = calloc(1, sizeof *surface);
+       surface = zalloc(sizeof *surface);
        if (!surface)
                return NULL;