Zero-initialize structs in init functions

Ensures there is no field left to its previous undefined value after
calling an init function.
This commit is contained in:
Simon Ser 2022-04-26 09:43:54 +02:00
parent 54653b5d95
commit 6c350799b2
20 changed files with 29 additions and 1 deletions

View file

@ -48,6 +48,7 @@ static struct wlr_scene *scene_node_get_root(struct wlr_scene_node *node) {
}
static void scene_node_state_init(struct wlr_scene_node_state *state) {
memset(state, 0, sizeof(*state));
wl_list_init(&state->children);
wl_list_init(&state->link);
state->enabled = true;
@ -61,6 +62,7 @@ static void scene_node_init(struct wlr_scene_node *node,
enum wlr_scene_node_type type, struct wlr_scene_node *parent) {
assert(type == WLR_SCENE_NODE_ROOT || parent != NULL);
memset(node, 0, sizeof(*node));
node->type = type;
node->parent = parent;
scene_node_state_init(&node->state);