common: Add additional memory utilities (xzalloc() etc.)

This commit is contained in:
John Lindgren 2022-09-16 18:41:02 -04:00
parent b89f7bfc0d
commit cb40cdc36c
35 changed files with 193 additions and 167 deletions

View file

@ -1,10 +1,10 @@
// SPDX-License-Identifier: GPL-2.0-only
#include <assert.h>
#include "common/mem.h"
#include "labwc.h"
#include "ssd.h"
#include "node.h"
#include "common/font.h"
/* Internal helpers */
static void
@ -24,7 +24,7 @@ static struct ssd_button *
ssd_button_descriptor_create(struct wlr_scene_node *node)
{
/* Create new ssd_button */
struct ssd_button *button = calloc(1, sizeof(struct ssd_button));
struct ssd_button *button = xzalloc(sizeof(struct ssd_button));
/* Let it destroy automatically when the scene node destroys */
button->destroy.notify = ssd_button_destroy_notify;
@ -39,7 +39,7 @@ ssd_button_descriptor_create(struct wlr_scene_node *node)
struct ssd_part *
add_scene_part(struct wl_list *part_list, enum ssd_part_type type)
{
struct ssd_part *part = calloc(1, sizeof(struct ssd_part));
struct ssd_part *part = xzalloc(sizeof(struct ssd_part));
part->type = type;
wl_list_insert(part_list->prev, &part->link);
return part;