examples: assert on memory allocation

Also checks for NULL output in the `X_from_device` functions
This commit is contained in:
Simon Zeni 2024-04-08 10:11:50 -04:00
parent ebef710746
commit 7cb206deb4
11 changed files with 39 additions and 1 deletions

View file

@ -72,6 +72,7 @@ static void server_handle_new_output(struct wl_listener *listener, void *data) {
wlr_output_init_render(wlr_output, server->allocator, server->renderer);
struct output *output = calloc(1, sizeof(*output));
assert(output);
output->wlr = wlr_output;
output->server = server;
output->frame.notify = output_handle_frame;
@ -124,6 +125,7 @@ static void server_handle_new_surface(struct wl_listener *listener,
server->surface_offset += 50;
struct surface *surface = calloc(1, sizeof(*surface));
assert(surface);
surface->wlr = wlr_surface;
surface->commit.notify = surface_handle_commit;
wl_signal_add(&wlr_surface->events.commit, &surface->commit);