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:
committed by
Kristian Høgsberg
parent
1c4f163c6d
commit
bc91926e0c
+2
-4
@@ -391,7 +391,7 @@ dnd_button_handler(struct widget *widget,
|
|||||||
y -= allocation.y;
|
y -= allocation.y;
|
||||||
|
|
||||||
if (item && state == WL_POINTER_BUTTON_STATE_PRESSED) {
|
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->dnd = dnd;
|
||||||
dnd_drag->input = input;
|
dnd_drag->input = input;
|
||||||
dnd_drag->time = time;
|
dnd_drag->time = time;
|
||||||
@@ -567,9 +567,7 @@ dnd_create(struct display *display)
|
|||||||
int32_t width, height;
|
int32_t width, height;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
dnd = malloc(sizeof *dnd);
|
dnd = xmalloc(sizeof *dnd);
|
||||||
if (dnd == NULL)
|
|
||||||
return dnd;
|
|
||||||
memset(dnd, 0, sizeof *dnd);
|
memset(dnd, 0, sizeof *dnd);
|
||||||
|
|
||||||
dnd->window = window_create(display);
|
dnd->window = window_create(display);
|
||||||
|
|||||||
+2
-1
@@ -501,7 +501,8 @@ text_entry_create(struct editor *editor, const char *text)
|
|||||||
{
|
{
|
||||||
struct text_entry *entry;
|
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->widget = widget_add_widget(editor->widget, entry);
|
||||||
entry->window = editor->window;
|
entry->window = editor->window;
|
||||||
|
|||||||
+2
-2
@@ -384,7 +384,7 @@ resize_handler(struct widget *widget,
|
|||||||
static char *
|
static char *
|
||||||
insert_text(const char *text, uint32_t offset, const char *insert)
|
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);
|
strncat(new_text, text, offset);
|
||||||
new_text[offset] = '\0';
|
new_text[offset] = '\0';
|
||||||
@@ -836,7 +836,7 @@ keyboard_create(struct output *output, struct virtual_keyboard *virtual_keyboard
|
|||||||
|
|
||||||
layout = get_current_layout(virtual_keyboard);
|
layout = get_current_layout(virtual_keyboard);
|
||||||
|
|
||||||
keyboard = malloc(sizeof *keyboard);
|
keyboard = xmalloc(sizeof *keyboard);
|
||||||
memset(keyboard, 0, sizeof *keyboard);
|
memset(keyboard, 0, sizeof *keyboard);
|
||||||
|
|
||||||
keyboard->keyboard = virtual_keyboard;
|
keyboard->keyboard = virtual_keyboard;
|
||||||
|
|||||||
+1
-3
@@ -233,9 +233,7 @@ resizor_create(struct display *display)
|
|||||||
{
|
{
|
||||||
struct resizor *resizor;
|
struct resizor *resizor;
|
||||||
|
|
||||||
resizor = malloc(sizeof *resizor);
|
resizor = xmalloc(sizeof *resizor);
|
||||||
if (resizor == NULL)
|
|
||||||
return resizor;
|
|
||||||
memset(resizor, 0, sizeof *resizor);
|
memset(resizor, 0, sizeof *resizor);
|
||||||
|
|
||||||
resizor->window = window_create(display);
|
resizor->window = window_create(display);
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ handle_global(void *data, struct wl_registry *registry,
|
|||||||
static struct screenshooter_output *output;
|
static struct screenshooter_output *output;
|
||||||
|
|
||||||
if (strcmp(interface, "wl_output") == 0) {
|
if (strcmp(interface, "wl_output") == 0) {
|
||||||
output = malloc(sizeof *output);
|
output = xmalloc(sizeof *output);
|
||||||
output->output = wl_registry_bind(registry, name,
|
output->output = wl_registry_bind(registry, name,
|
||||||
&wl_output_interface, 1);
|
&wl_output_interface, 1);
|
||||||
wl_list_insert(&output_list, &output->link);
|
wl_list_insert(&output_list, &output->link);
|
||||||
|
|||||||
@@ -489,7 +489,8 @@ triangle_create(struct window *window, struct egl_state *egl)
|
|||||||
{
|
{
|
||||||
struct triangle *tri;
|
struct triangle *tri;
|
||||||
|
|
||||||
tri = calloc(1, sizeof *tri);
|
tri = xmalloc(sizeof *tri);
|
||||||
|
memset(tri, 0, sizeof *tri);
|
||||||
|
|
||||||
tri->egl = egl;
|
tri->egl = egl;
|
||||||
tri->widget = window_add_subsurface(window, tri,
|
tri->widget = window_add_subsurface(window, tri,
|
||||||
@@ -709,9 +710,8 @@ demoapp_create(struct display *display)
|
|||||||
{
|
{
|
||||||
struct demoapp *app;
|
struct demoapp *app;
|
||||||
|
|
||||||
app = calloc(1, sizeof *app);
|
app = xmalloc(sizeof *app);
|
||||||
if (!app)
|
memset(app, 0, sizeof *app);
|
||||||
return NULL;
|
|
||||||
|
|
||||||
app->egl = egl_state_create(display_get_display(display));
|
app->egl = egl_state_create(display_get_display(display));
|
||||||
|
|
||||||
|
|||||||
@@ -230,7 +230,7 @@ homescreen_create(struct tablet *tablet)
|
|||||||
{
|
{
|
||||||
struct homescreen *homescreen;
|
struct homescreen *homescreen;
|
||||||
|
|
||||||
homescreen = malloc (sizeof *homescreen);
|
homescreen = xmalloc(sizeof *homescreen);
|
||||||
memset(homescreen, 0, sizeof *homescreen);
|
memset(homescreen, 0, sizeof *homescreen);
|
||||||
|
|
||||||
homescreen->window = window_create_custom(tablet->display);
|
homescreen->window = window_create_custom(tablet->display);
|
||||||
@@ -248,7 +248,7 @@ lockscreen_create(struct tablet *tablet)
|
|||||||
{
|
{
|
||||||
struct lockscreen *lockscreen;
|
struct lockscreen *lockscreen;
|
||||||
|
|
||||||
lockscreen = malloc (sizeof *lockscreen);
|
lockscreen = xmalloc(sizeof *lockscreen);
|
||||||
memset(lockscreen, 0, sizeof *lockscreen);
|
memset(lockscreen, 0, sizeof *lockscreen);
|
||||||
|
|
||||||
lockscreen->window = window_create_custom(tablet->display);
|
lockscreen->window = window_create_custom(tablet->display);
|
||||||
@@ -395,7 +395,7 @@ tablet_shell_add_launcher(struct tablet *tablet,
|
|||||||
struct launcher *launcher;
|
struct launcher *launcher;
|
||||||
struct homescreen *homescreen = tablet->homescreen;
|
struct homescreen *homescreen = tablet->homescreen;
|
||||||
|
|
||||||
launcher = malloc(sizeof *launcher);
|
launcher = xmalloc(sizeof *launcher);
|
||||||
launcher->icon = load_cairo_surface(icon);
|
launcher->icon = load_cairo_surface(icon);
|
||||||
if ( !launcher->icon ||
|
if ( !launcher->icon ||
|
||||||
cairo_surface_status (launcher->icon) != CAIRO_STATUS_SUCCESS) {
|
cairo_surface_status (launcher->icon) != CAIRO_STATUS_SUCCESS) {
|
||||||
|
|||||||
+1
-3
@@ -2552,9 +2552,7 @@ terminal_create(struct display *display)
|
|||||||
cairo_t *cr;
|
cairo_t *cr;
|
||||||
cairo_text_extents_t text_extents;
|
cairo_text_extents_t text_extents;
|
||||||
|
|
||||||
terminal = malloc(sizeof *terminal);
|
terminal = xmalloc(sizeof *terminal);
|
||||||
if (terminal == NULL)
|
|
||||||
return terminal;
|
|
||||||
|
|
||||||
memset(terminal, 0, sizeof *terminal);
|
memset(terminal, 0, sizeof *terminal);
|
||||||
terminal->color_scheme = &DEFAULT_COLORS;
|
terminal->color_scheme = &DEFAULT_COLORS;
|
||||||
|
|||||||
+11
-8
@@ -1164,7 +1164,9 @@ shm_surface_create(struct display *display, struct wl_surface *wl_surface,
|
|||||||
struct shm_surface *surface;
|
struct shm_surface *surface;
|
||||||
DBG_OBJ(wl_surface, "\n");
|
DBG_OBJ(wl_surface, "\n");
|
||||||
|
|
||||||
surface = calloc(1, sizeof *surface);
|
surface = xmalloc(sizeof *surface);
|
||||||
|
memset(surface, 0, sizeof *surface);
|
||||||
|
|
||||||
if (!surface)
|
if (!surface)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@@ -1309,7 +1311,7 @@ create_cursors(struct display *display)
|
|||||||
|
|
||||||
display->cursor_theme = wl_cursor_theme_load(theme, size, display->shm);
|
display->cursor_theme = wl_cursor_theme_load(theme, size, display->shm);
|
||||||
display->cursors =
|
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++) {
|
for (i = 0; i < ARRAY_LENGTH(cursors); i++) {
|
||||||
cursor = NULL;
|
cursor = NULL;
|
||||||
@@ -1606,7 +1608,7 @@ widget_create(struct window *window, struct surface *surface, void *data)
|
|||||||
{
|
{
|
||||||
struct widget *widget;
|
struct widget *widget;
|
||||||
|
|
||||||
widget = malloc(sizeof *widget);
|
widget = xmalloc(sizeof *widget);
|
||||||
memset(widget, 0, sizeof *widget);
|
memset(widget, 0, sizeof *widget);
|
||||||
widget->window = window;
|
widget->window = window;
|
||||||
widget->surface = surface;
|
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;
|
struct frame_button *frame_button;
|
||||||
const char *icon = data;
|
const char *icon = data;
|
||||||
|
|
||||||
frame_button = malloc (sizeof *frame_button);
|
frame_button = xmalloc(sizeof *frame_button);
|
||||||
memset(frame_button, 0, sizeof *frame_button);
|
memset(frame_button, 0, sizeof *frame_button);
|
||||||
|
|
||||||
frame_button->icon = cairo_image_surface_create_from_png(icon);
|
frame_button->icon = cairo_image_surface_create_from_png(icon);
|
||||||
@@ -3229,7 +3231,7 @@ data_device_data_offer(void *data,
|
|||||||
{
|
{
|
||||||
struct data_offer *offer;
|
struct data_offer *offer;
|
||||||
|
|
||||||
offer = malloc(sizeof *offer);
|
offer = xmalloc(sizeof *offer);
|
||||||
|
|
||||||
wl_array_init(&offer->types);
|
wl_array_init(&offer->types);
|
||||||
offer->refcount = 1;
|
offer->refcount = 1;
|
||||||
@@ -4138,7 +4140,7 @@ surface_enter(void *data,
|
|||||||
if (!output_found)
|
if (!output_found)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
window_output = malloc (sizeof *window_output);
|
window_output = xmalloc(sizeof *window_output);
|
||||||
window_output->output = output_found;
|
window_output->output = output_found;
|
||||||
|
|
||||||
wl_list_insert (&window->window_output_list, &window_output->link);
|
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 display *display = window->display;
|
||||||
struct surface *surface;
|
struct surface *surface;
|
||||||
|
|
||||||
surface = calloc(1, sizeof *surface);
|
surface = xmalloc(sizeof *surface);
|
||||||
|
memset(surface, 0, sizeof *surface);
|
||||||
if (!surface)
|
if (!surface)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@@ -4773,7 +4776,7 @@ registry_handle_global(void *data, struct wl_registry *registry, uint32_t id,
|
|||||||
struct display *d = data;
|
struct display *d = data;
|
||||||
struct global *global;
|
struct global *global;
|
||||||
|
|
||||||
global = malloc(sizeof *global);
|
global = xmalloc(sizeof *global);
|
||||||
global->name = id;
|
global->name = id;
|
||||||
global->interface = strdup(interface);
|
global->interface = strdup(interface);
|
||||||
global->version = version;
|
global->version = version;
|
||||||
|
|||||||
Reference in New Issue
Block a user