mirror of
https://github.com/labwc/labwc.git
synced 2026-06-13 14:33:18 -04:00
tree-wide: use die_if_null() for wlr_scene alloc failures
Some checks failed
labwc.github.io / notify (push) Has been cancelled
Some checks failed
labwc.github.io / notify (push) Has been cancelled
wlr_scene_*_create() functions all allocate memory via calloc() and return NULL if the allocation fails. Previously, the failures were handled in any of 3 different ways: - sending a wayland protocol error - exiting labwc with an error - segfault (no NULL check at all) Since labwc does not attempt to survive heap exhaustion in other allocation paths (such as `znew`), it seems more consistent to use the same die_if_null() check used in those paths to exit with an error. For the three most common create() functions (tree, rect, buffer), add small lab_wlr_ wrappers to common/scene-helpers.
This commit is contained in:
parent
c4effef0ec
commit
16c5373be5
27 changed files with 155 additions and 141 deletions
|
|
@ -5,6 +5,7 @@
|
|||
#include <wlr/types/wlr_output.h>
|
||||
#include <wlr/types/wlr_scene.h>
|
||||
#include <wlr/util/log.h>
|
||||
#include "common/mem.h"
|
||||
#include "magnifier.h"
|
||||
#include "output.h"
|
||||
|
||||
|
|
@ -24,6 +25,34 @@ lab_wlr_surface_from_node(struct wlr_scene_node *node)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
struct wlr_scene_tree *
|
||||
lab_wlr_scene_tree_create(struct wlr_scene_tree *parent)
|
||||
{
|
||||
struct wlr_scene_tree *tree = wlr_scene_tree_create(parent);
|
||||
die_if_null(tree);
|
||||
return tree;
|
||||
}
|
||||
|
||||
struct wlr_scene_rect *
|
||||
lab_wlr_scene_rect_create(struct wlr_scene_tree *parent,
|
||||
int width, int height, const float color[static 4])
|
||||
{
|
||||
struct wlr_scene_rect *rect =
|
||||
wlr_scene_rect_create(parent, width, height, color);
|
||||
die_if_null(rect);
|
||||
return rect;
|
||||
}
|
||||
|
||||
struct wlr_scene_buffer *
|
||||
lab_wlr_scene_buffer_create(struct wlr_scene_tree *parent,
|
||||
struct wlr_buffer *buffer)
|
||||
{
|
||||
struct wlr_scene_buffer *scene_buffer =
|
||||
wlr_scene_buffer_create(parent, buffer);
|
||||
die_if_null(scene_buffer);
|
||||
return scene_buffer;
|
||||
}
|
||||
|
||||
struct wlr_scene_node *
|
||||
lab_wlr_scene_get_prev_node(struct wlr_scene_node *node)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue