mirror of
https://github.com/labwc/labwc.git
synced 2025-11-05 13:29:58 -05:00
common: Add additional memory utilities (xzalloc() etc.)
This commit is contained in:
parent
b89f7bfc0d
commit
cb40cdc36c
35 changed files with 193 additions and 167 deletions
|
|
@ -3,6 +3,7 @@
|
|||
#include "labwc.h"
|
||||
#include "ssd.h"
|
||||
#include "theme.h"
|
||||
#include "common/mem.h"
|
||||
#include "common/scene-helpers.h"
|
||||
|
||||
static struct ssd_part *
|
||||
|
|
@ -18,7 +19,7 @@ add_extent(struct wl_list *part_list, enum ssd_part_type type,
|
|||
* part->geometry will get free'd automatically in ssd_destroy_parts().
|
||||
*/
|
||||
part->node = &wlr_scene_rect_create(parent, 0, 0, invisible)->node;
|
||||
part->geometry = calloc(1, sizeof(struct wlr_box));
|
||||
part->geometry = xzalloc(sizeof(struct wlr_box));
|
||||
return part;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
#include "ssd.h"
|
||||
#include "theme.h"
|
||||
#include "common/font.h"
|
||||
#include "common/mem.h"
|
||||
#include "common/scaled_font_buffer.h"
|
||||
#include "common/scene-helpers.h"
|
||||
#include "node.h"
|
||||
|
|
@ -271,7 +272,7 @@ ssd_update_title(struct view *view)
|
|||
if (state->text) {
|
||||
free(state->text);
|
||||
}
|
||||
state->text = strdup(title);
|
||||
state->text = xstrdup(title);
|
||||
}
|
||||
ssd_update_title_positions(view);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue