clients: Use zalloc
Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
diff --git a/clients/desktop-shell.c b/clients/desktop-shell.c
index 6ab76dc..49a3077 100644
--- a/clients/desktop-shell.c
+++ b/clients/desktop-shell.c
@@ -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 @@
{
struct output *output;
- output = calloc(1, sizeof *output);
+ output = zalloc(sizeof *output);
if (!output)
return;
diff --git a/clients/fullscreen.c b/clients/fullscreen.c
index 653372a..e2e6477 100644
--- a/clients/fullscreen.c
+++ b/clients/fullscreen.c
@@ -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 @@
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);
}
diff --git a/clients/ivi-shell-user-interface.c b/clients/ivi-shell-user-interface.c
index 2e0622b..1349c73 100644
--- a/clients/ivi-shell-user-interface.c
+++ b/clients/ivi-shell-user-interface.c
@@ -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 @@
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__)
diff --git a/clients/multi-resource.c b/clients/multi-resource.c
index c30d38a..4ed4d50 100644
--- a/clients/multi-resource.c
+++ b/clients/multi-resource.c
@@ -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 @@
{
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);
diff --git a/clients/presentation-shm.c b/clients/presentation-shm.c
index 1feeb36..2d9b885 100644
--- a/clients/presentation-shm.c
+++ b/clients/presentation-shm.c
@@ -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 @@
"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 @@
if (!pres)
return;
- feedback = calloc(1, sizeof *feedback);
+ feedback = zalloc(sizeof *feedback);
if (!feedback)
return;
@@ -678,7 +679,7 @@
{
struct output *o;
- o = calloc(1, sizeof(*o));
+ o = zalloc(sizeof(*o));
assert(o);
o->output = wl_registry_bind(d->registry, name,
diff --git a/clients/simple-damage.c b/clients/simple-damage.c
index 0353ccc..321b90f 100644
--- a/clients/simple-damage.c
+++ b/clients/simple-damage.c
@@ -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 @@
exit(1);
}
- window = calloc(1, sizeof *window);
+ window = zalloc(sizeof *window);
if (!window)
return NULL;
diff --git a/clients/simple-dmabuf-intel.c b/clients/simple-dmabuf-intel.c
index 0ceefeb..2ac2200 100644
--- a/clients/simple-dmabuf-intel.c
+++ b/clients/simple-dmabuf-intel.c
@@ -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 @@
int i;
int ret;
- window = calloc(1, sizeof *window);
+ window = zalloc(sizeof *window);
if (!window)
return NULL;
diff --git a/clients/simple-dmabuf-v4l.c b/clients/simple-dmabuf-v4l.c
index 29e41ac..a73556c 100644
--- a/clients/simple-dmabuf-v4l.c
+++ b/clients/simple-dmabuf-v4l.c
@@ -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 @@
{
struct window *window;
- window = calloc(1, sizeof *window);
+ window = zalloc(sizeof *window);
if (!window)
return NULL;
diff --git a/clients/simple-shm.c b/clients/simple-shm.c
index e6f0bd0..6d8f608 100644
--- a/clients/simple-shm.c
+++ b/clients/simple-shm.c
@@ -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 @@
{
struct window *window;
- window = calloc(1, sizeof *window);
+ window = zalloc(sizeof *window);
if (!window)
return NULL;
diff --git a/clients/subsurfaces.c b/clients/subsurfaces.c
index b971fdf..bf0b96b 100644
--- a/clients/subsurfaces.c
+++ b/clients/subsurfaces.c
@@ -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 @@
EGLint major, minor, n;
EGLBoolean ret;
- egl = calloc(1, sizeof *egl);
+ egl = zalloc(sizeof *egl);
assert(egl);
egl->dpy =
diff --git a/clients/weston-info.c b/clients/weston-info.c
index 9d42599..e277f88 100644
--- a/clients/weston-info.c
+++ b/clients/weston-info.c
@@ -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 @@
static void *
xzalloc(size_t s)
{
- return fail_on_null(calloc(1, s));
+ return fail_on_null(zalloc(s));
}
static char *
diff --git a/clients/window.c b/clients/window.c
index 35261b6..ced867e 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -68,6 +68,7 @@
#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 @@
if (display->dpy == EGL_NO_DISPLAY)
return NULL;
- surface = calloc(1, sizeof *surface);
+ surface = zalloc(sizeof *surface);
if (!surface)
return NULL;