summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryce Harrington <bryce@osg.samsung.com>2016-02-11 16:42:49 -0800
committerBryce Harrington <bryce@osg.samsung.com>2016-03-09 22:54:54 -0800
commit0d1a6223751242387f1fe62c8da508d6035d7fbd (patch)
tree2b0aa6fbd816b21b1de78595300da67dfe09a614
parentcd9424ef2a8face5d64b086bc55ab4e70e077beb (diff)
clients: Use zalloc
Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
-rw-r--r--clients/desktop-shell.c3
-rw-r--r--clients/fullscreen.c7
-rw-r--r--clients/ivi-shell-user-interface.c3
-rw-r--r--clients/multi-resource.c3
-rw-r--r--clients/presentation-shm.c7
-rw-r--r--clients/simple-damage.c3
-rw-r--r--clients/simple-dmabuf-intel.c3
-rw-r--r--clients/simple-dmabuf-v4l.c3
-rw-r--r--clients/simple-shm.c3
-rw-r--r--clients/subsurfaces.c3
-rw-r--r--clients/weston-info.c3
-rw-r--r--clients/window.c3
12 files changed, 30 insertions, 14 deletions
diff --git a/clients/desktop-shell.c b/clients/desktop-shell.c
index 6ab76dc7..49a3077a 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 @@ create_output(struct desktop *desktop, uint32_t id)
{
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 653372a3..e2e6477f 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 @@ 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);
}
diff --git a/clients/ivi-shell-user-interface.c b/clients/ivi-shell-user-interface.c
index 2e0622b9..1349c733 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 @@ 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__)
diff --git a/clients/multi-resource.c b/clients/multi-resource.c
index c30d38a0..4ed4d500 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 @@ 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);
diff --git a/clients/presentation-shm.c b/clients/presentation-shm.c
index 1feeb365..2d9b8852 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 @@ 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,
diff --git a/clients/simple-damage.c b/clients/simple-damage.c
index 0353cccb..321b90fc 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 @@ create_window(struct display *display, int width, int height,
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 0ceefebb..2ac22005 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 @@ 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;
diff --git a/clients/simple-dmabuf-v4l.c b/clients/simple-dmabuf-v4l.c
index 29e41ace..a73556c8 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 @@ create_window(struct display *display)
{
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 e6f0bd0b..6d8f6084 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 @@ 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;
diff --git a/clients/subsurfaces.c b/clients/subsurfaces.c
index b971fdff..bf0b96b7 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 @@ 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 =
diff --git a/clients/weston-info.c b/clients/weston-info.c
index 9d42599a..e277f885 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 @@ 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 *
diff --git a/clients/window.c b/clients/window.c
index 35261b63..ced867ef 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -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;