mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-28 01:40:17 -05:00
Convert most dynamic allocations to use functions from xmalloc.h
This commit is contained in:
parent
ecb2695822
commit
7a77958ba2
21 changed files with 133 additions and 68 deletions
10
fdm.c
10
fdm.c
|
|
@ -50,6 +50,11 @@ fdm_init(void)
|
|||
}
|
||||
|
||||
struct fdm *fdm = malloc(sizeof(*fdm));
|
||||
if (unlikely(fdm == NULL)) {
|
||||
LOG_ERRNO("malloc() failed");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
*fdm = (struct fdm){
|
||||
.epoll_fd = epoll_fd,
|
||||
.is_polling = false,
|
||||
|
|
@ -114,6 +119,11 @@ fdm_add(struct fdm *fdm, int fd, int events, fdm_handler_t handler, void *data)
|
|||
#endif
|
||||
|
||||
struct handler *fd_data = malloc(sizeof(*fd_data));
|
||||
if (unlikely(fd_data == NULL)) {
|
||||
LOG_ERRNO("malloc() failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
*fd_data = (struct handler) {
|
||||
.fd = fd,
|
||||
.events = events,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue