diff options
| author | Craig Barnes <craigbarnes@protonmail.com> | 2020-08-08 19:34:30 +0000 |
|---|---|---|
| committer | Craig Barnes <craigbarnes@protonmail.com> | 2020-08-08 19:37:57 +0000 |
| commit | 7a77958ba20c2b344be5e66e69e2f212a4bbf6b3 (patch) | |
| tree | cdb8191177f5f9ca69ea7858f9543f36fcbcf616 /fdm.c | |
| parent | changelog: add birger to 'contributers' for the upcoming release (diff) | |
Convert most dynamic allocations to use functions from xmalloc.h
Diffstat (limited to 'fdm.c')
| -rw-r--r-- | fdm.c | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -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, |
