mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
Handle allocation failures explicitly in *_init() functions
This commit is contained in:
parent
7a77958ba2
commit
4e6100494c
2 changed files with 20 additions and 4 deletions
10
reaper.c
10
reaper.c
|
|
@ -10,7 +10,6 @@
|
||||||
#define LOG_ENABLE_DBG 0
|
#define LOG_ENABLE_DBG 0
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "tllist.h"
|
#include "tllist.h"
|
||||||
#include "xmalloc.h"
|
|
||||||
|
|
||||||
struct reaper {
|
struct reaper {
|
||||||
struct fdm *fdm;
|
struct fdm *fdm;
|
||||||
|
|
@ -40,7 +39,14 @@ reaper_init(struct fdm *fdm)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct reaper *reaper = xmalloc(sizeof(*reaper));
|
struct reaper *reaper = malloc(sizeof(*reaper));
|
||||||
|
if (unlikely(reaper == NULL)) {
|
||||||
|
LOG_ERRNO("malloc() failed");
|
||||||
|
close(fd);
|
||||||
|
sigprocmask(SIG_UNBLOCK, &mask, NULL);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
*reaper = (struct reaper){
|
*reaper = (struct reaper){
|
||||||
.fdm = fdm,
|
.fdm = fdm,
|
||||||
.fd = fd,
|
.fd = fd,
|
||||||
|
|
|
||||||
14
wayland.c
14
wayland.c
|
|
@ -974,7 +974,12 @@ fdm_wayl(struct fdm *fdm, int fd, int events, void *data)
|
||||||
struct wayland *
|
struct wayland *
|
||||||
wayl_init(const struct config *conf, struct fdm *fdm)
|
wayl_init(const struct config *conf, struct fdm *fdm)
|
||||||
{
|
{
|
||||||
struct wayland *wayl = xcalloc(1, sizeof(*wayl));
|
struct wayland *wayl = calloc(1, sizeof(*wayl));
|
||||||
|
if (unlikely(wayl == NULL)) {
|
||||||
|
LOG_ERRNO("calloc() failed");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
wayl->conf = conf;
|
wayl->conf = conf;
|
||||||
wayl->fdm = fdm;
|
wayl->fdm = fdm;
|
||||||
wayl->fd = -1;
|
wayl->fd = -1;
|
||||||
|
|
@ -1131,7 +1136,12 @@ wayl_win_init(struct terminal *term)
|
||||||
struct wayland *wayl = term->wl;
|
struct wayland *wayl = term->wl;
|
||||||
const struct config *conf = term->conf;
|
const struct config *conf = term->conf;
|
||||||
|
|
||||||
struct wl_window *win = xcalloc(1, sizeof(*win));
|
struct wl_window *win = calloc(1, sizeof(*win));
|
||||||
|
if (unlikely(win == NULL)) {
|
||||||
|
LOG_ERRNO("calloc() failed");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
win->term = term;
|
win->term = term;
|
||||||
win->use_csd = CSD_UNKNOWN;
|
win->use_csd = CSD_UNKNOWN;
|
||||||
win->csd.move_timeout_fd = -1;
|
win->csd.move_timeout_fd = -1;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue