mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2026-04-17 06:46:39 -04:00
examples: assert on memory allocation
Also checks for NULL output in the `X_from_device` functions
This commit is contained in:
parent
ebef710746
commit
7cb206deb4
11 changed files with 39 additions and 1 deletions
|
|
@ -193,6 +193,7 @@ static void handle_touch_down(struct wl_listener *listener, void *data) {
|
|||
struct sample_state *sample = wl_container_of(listener, sample, touch_down);
|
||||
struct wlr_touch_down_event *event = data;
|
||||
struct touch_point *point = calloc(1, sizeof(*point));
|
||||
assert(point);
|
||||
point->touch_id = event->touch_id;
|
||||
point->x = event->x;
|
||||
point->y = event->y;
|
||||
|
|
@ -265,6 +266,7 @@ static void new_output_notify(struct wl_listener *listener, void *data) {
|
|||
wlr_output_init_render(output, sample->allocator, sample->renderer);
|
||||
|
||||
struct sample_output *sample_output = calloc(1, sizeof(*sample_output));
|
||||
assert(sample_output);
|
||||
sample_output->output = output;
|
||||
sample_output->state = sample;
|
||||
wl_signal_add(&output->events.frame, &sample_output->frame);
|
||||
|
|
@ -304,7 +306,9 @@ static void new_input_notify(struct wl_listener *listener, void *data) {
|
|||
|
||||
case WLR_INPUT_DEVICE_KEYBOARD:;
|
||||
struct sample_keyboard *keyboard = calloc(1, sizeof(*keyboard));
|
||||
assert(keyboard);
|
||||
keyboard->wlr_keyboard = wlr_keyboard_from_input_device(device);
|
||||
assert(keyboard->wlr_keyboard);
|
||||
keyboard->state = state;
|
||||
wl_signal_add(&device->events.destroy, &keyboard->destroy);
|
||||
keyboard->destroy.notify = keyboard_destroy_notify;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue