clients: use xmalloc in more places
For the clients continue to use xmalloc() to simplify OOM-handling.
Signed-off-by: Brian Lovin <brian.j.lovin@intel.com>
diff --git a/clients/window.c b/clients/window.c
index b9045f3..ac35285 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -1164,7 +1164,9 @@
struct shm_surface *surface;
DBG_OBJ(wl_surface, "\n");
- surface = calloc(1, sizeof *surface);
+ surface = xmalloc(sizeof *surface);
+ memset(surface, 0, sizeof *surface);
+
if (!surface)
return NULL;
@@ -1309,7 +1311,7 @@
display->cursor_theme = wl_cursor_theme_load(theme, size, display->shm);
display->cursors =
- malloc(ARRAY_LENGTH(cursors) * sizeof display->cursors[0]);
+ xmalloc(ARRAY_LENGTH(cursors) * sizeof display->cursors[0]);
for (i = 0; i < ARRAY_LENGTH(cursors); i++) {
cursor = NULL;
@@ -1606,7 +1608,7 @@
{
struct widget *widget;
- widget = malloc(sizeof *widget);
+ widget = xmalloc(sizeof *widget);
memset(widget, 0, sizeof *widget);
widget->window = window;
widget->surface = surface;
@@ -2388,7 +2390,7 @@
struct frame_button *frame_button;
const char *icon = data;
- frame_button = malloc (sizeof *frame_button);
+ frame_button = xmalloc(sizeof *frame_button);
memset(frame_button, 0, sizeof *frame_button);
frame_button->icon = cairo_image_surface_create_from_png(icon);
@@ -3229,7 +3231,7 @@
{
struct data_offer *offer;
- offer = malloc(sizeof *offer);
+ offer = xmalloc(sizeof *offer);
wl_array_init(&offer->types);
offer->refcount = 1;
@@ -4138,7 +4140,7 @@
if (!output_found)
return;
- window_output = malloc (sizeof *window_output);
+ window_output = xmalloc(sizeof *window_output);
window_output->output = output_found;
wl_list_insert (&window->window_output_list, &window_output->link);
@@ -4185,7 +4187,8 @@
struct display *display = window->display;
struct surface *surface;
- surface = calloc(1, sizeof *surface);
+ surface = xmalloc(sizeof *surface);
+ memset(surface, 0, sizeof *surface);
if (!surface)
return NULL;
@@ -4773,7 +4776,7 @@
struct display *d = data;
struct global *global;
- global = malloc(sizeof *global);
+ global = xmalloc(sizeof *global);
global->name = id;
global->interface = strdup(interface);
global->version = version;