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
|
||||
#include "log.h"
|
||||
#include "tllist.h"
|
||||
#include "xmalloc.h"
|
||||
|
||||
struct reaper {
|
||||
struct fdm *fdm;
|
||||
|
|
@ -40,7 +39,14 @@ reaper_init(struct fdm *fdm)
|
|||
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){
|
||||
.fdm = fdm,
|
||||
.fd = fd,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue