multi-resource: Use xzmalloc() instead of malloc+memset and calloc

dev
Kristian Høgsberg 11 years ago
parent 74b0d72817
commit b24d590e8f
  1. 18
      clients/multi-resource.c

@ -39,6 +39,7 @@
#include <wayland-client.h>
#include "../shared/os-compatibility.h"
#include "xmalloc.h"
struct device {
enum { KEYBOARD, POINTER } type;
@ -140,10 +141,7 @@ create_window(struct display *display, int width, int height)
{
struct window *window;
window = calloc(1, sizeof *window);
if (!window)
return NULL;
window = xzalloc(sizeof *window);
window->display = display;
window->width = width;
window->height = height;
@ -226,12 +224,7 @@ create_display(void)
{
struct display *display;
display = malloc(sizeof *display);
if (display == NULL) {
fprintf(stderr, "out of memory\n");
exit(1);
}
memset(display, 0, sizeof *display);
display = xzalloc(sizeof *display);
display->display = wl_display_connect(NULL);
assert(display->display);
@ -452,8 +445,7 @@ create_device(struct display *display, const char *time_desc, int type)
goto error;
}
device = malloc(sizeof *device);
memset(device, 0, sizeof(*device));
device = xzalloc(sizeof *device);
device->type = type;
device->start_time = start_time;
device->end_time = end_time;
@ -552,8 +544,6 @@ main(int argc, char **argv)
display = create_display();
window = create_window(display, 250, 250);
if (!window)
return 1;
for (i = 1; i < argc; i++) {
if (!strncmp(argv[i], "-p", 2)) {

Loading…
Cancel
Save