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>
This commit is contained in:
parent
1c4f163c6d
commit
bc91926e0c
@ -391,7 +391,7 @@ dnd_button_handler(struct widget *widget,
|
||||
y -= allocation.y;
|
||||
|
||||
if (item && state == WL_POINTER_BUTTON_STATE_PRESSED) {
|
||||
dnd_drag = malloc(sizeof *dnd_drag);
|
||||
dnd_drag = xmalloc(sizeof *dnd_drag);
|
||||
dnd_drag->dnd = dnd;
|
||||
dnd_drag->input = input;
|
||||
dnd_drag->time = time;
|
||||
@ -567,9 +567,7 @@ dnd_create(struct display *display)
|
||||
int32_t width, height;
|
||||
unsigned int i;
|
||||
|
||||
dnd = malloc(sizeof *dnd);
|
||||
if (dnd == NULL)
|
||||
return dnd;
|
||||
dnd = xmalloc(sizeof *dnd);
|
||||
memset(dnd, 0, sizeof *dnd);
|
||||
|
||||
dnd->window = window_create(display);
|
||||
|
@ -501,7 +501,8 @@ text_entry_create(struct editor *editor, const char *text)
|
||||
{
|
||||
struct text_entry *entry;
|
||||
|
||||
entry = calloc(1, sizeof *entry);
|
||||
entry = xmalloc(sizeof *entry);
|
||||
memset(entry, 0, sizeof *entry);
|
||||
|
||||
entry->widget = widget_add_widget(editor->widget, entry);
|
||||
entry->window = editor->window;
|
||||
|
@ -384,7 +384,7 @@ resize_handler(struct widget *widget,
|
||||
static char *
|
||||
insert_text(const char *text, uint32_t offset, const char *insert)
|
||||
{
|
||||
char *new_text = malloc(strlen(text) + strlen(insert) + 1);
|
||||
char *new_text = xmalloc(strlen(text) + strlen(insert) + 1);
|
||||
|
||||
strncat(new_text, text, offset);
|
||||
new_text[offset] = '\0';
|
||||
@ -836,7 +836,7 @@ keyboard_create(struct output *output, struct virtual_keyboard *virtual_keyboard
|
||||
|
||||
layout = get_current_layout(virtual_keyboard);
|
||||
|
||||
keyboard = malloc(sizeof *keyboard);
|
||||
keyboard = xmalloc(sizeof *keyboard);
|
||||
memset(keyboard, 0, sizeof *keyboard);
|
||||
|
||||
keyboard->keyboard = virtual_keyboard;
|
||||
|
@ -233,9 +233,7 @@ resizor_create(struct display *display)
|
||||
{
|
||||
struct resizor *resizor;
|
||||
|
||||
resizor = malloc(sizeof *resizor);
|
||||
if (resizor == NULL)
|
||||
return resizor;
|
||||
resizor = xmalloc(sizeof *resizor);
|
||||
memset(resizor, 0, sizeof *resizor);
|
||||
|
||||
resizor->window = window_create(display);
|
||||
|
@ -115,7 +115,7 @@ handle_global(void *data, struct wl_registry *registry,
|
||||
static struct screenshooter_output *output;
|
||||
|
||||
if (strcmp(interface, "wl_output") == 0) {
|
||||
output = malloc(sizeof *output);
|
||||
output = xmalloc(sizeof *output);
|
||||
output->output = wl_registry_bind(registry, name,
|
||||
&wl_output_interface, 1);
|
||||
wl_list_insert(&output_list, &output->link);
|
||||
|
@ -489,7 +489,8 @@ triangle_create(struct window *window, struct egl_state *egl)
|
||||
{
|
||||
struct triangle *tri;
|
||||
|
||||
tri = calloc(1, sizeof *tri);
|
||||
tri = xmalloc(sizeof *tri);
|
||||
memset(tri, 0, sizeof *tri);
|
||||
|
||||
tri->egl = egl;
|
||||
tri->widget = window_add_subsurface(window, tri,
|
||||
@ -709,9 +710,8 @@ demoapp_create(struct display *display)
|
||||
{
|
||||
struct demoapp *app;
|
||||
|
||||
app = calloc(1, sizeof *app);
|
||||
if (!app)
|
||||
return NULL;
|
||||
app = xmalloc(sizeof *app);
|
||||
memset(app, 0, sizeof *app);
|
||||
|
||||
app->egl = egl_state_create(display_get_display(display));
|
||||
|
||||
|
@ -230,7 +230,7 @@ homescreen_create(struct tablet *tablet)
|
||||
{
|
||||
struct homescreen *homescreen;
|
||||
|
||||
homescreen = malloc (sizeof *homescreen);
|
||||
homescreen = xmalloc(sizeof *homescreen);
|
||||
memset(homescreen, 0, sizeof *homescreen);
|
||||
|
||||
homescreen->window = window_create_custom(tablet->display);
|
||||
@ -248,7 +248,7 @@ lockscreen_create(struct tablet *tablet)
|
||||
{
|
||||
struct lockscreen *lockscreen;
|
||||
|
||||
lockscreen = malloc (sizeof *lockscreen);
|
||||
lockscreen = xmalloc(sizeof *lockscreen);
|
||||
memset(lockscreen, 0, sizeof *lockscreen);
|
||||
|
||||
lockscreen->window = window_create_custom(tablet->display);
|
||||
@ -395,7 +395,7 @@ tablet_shell_add_launcher(struct tablet *tablet,
|
||||
struct launcher *launcher;
|
||||
struct homescreen *homescreen = tablet->homescreen;
|
||||
|
||||
launcher = malloc(sizeof *launcher);
|
||||
launcher = xmalloc(sizeof *launcher);
|
||||
launcher->icon = load_cairo_surface(icon);
|
||||
if ( !launcher->icon ||
|
||||
cairo_surface_status (launcher->icon) != CAIRO_STATUS_SUCCESS) {
|
||||
|
@ -2552,9 +2552,7 @@ terminal_create(struct display *display)
|
||||
cairo_t *cr;
|
||||
cairo_text_extents_t text_extents;
|
||||
|
||||
terminal = malloc(sizeof *terminal);
|
||||
if (terminal == NULL)
|
||||
return terminal;
|
||||
terminal = xmalloc(sizeof *terminal);
|
||||
|
||||
memset(terminal, 0, sizeof *terminal);
|
||||
terminal->color_scheme = &DEFAULT_COLORS;
|
||||
|
@ -1164,7 +1164,9 @@ shm_surface_create(struct display *display, struct wl_surface *wl_surface,
|
||||
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 @@ create_cursors(struct display *display)
|
||||
|
||||
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 @@ widget_create(struct window *window, struct surface *surface, void *data)
|
||||
{
|
||||
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 @@ frame_button_create(struct frame *frame, void *data, enum frame_button_action ty
|
||||
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 @@ data_device_data_offer(void *data,
|
||||
{
|
||||
struct data_offer *offer;
|
||||
|
||||
offer = malloc(sizeof *offer);
|
||||
offer = xmalloc(sizeof *offer);
|
||||
|
||||
wl_array_init(&offer->types);
|
||||
offer->refcount = 1;
|
||||
@ -4138,7 +4140,7 @@ surface_enter(void *data,
|
||||
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 @@ surface_create(struct window *window)
|
||||
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 @@ registry_handle_global(void *data, struct wl_registry *registry, uint32_t id,
|
||||
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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user