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 /render.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 'render.c')
| -rw-r--r-- | render.c | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -22,6 +22,7 @@ #include "selection.h" #include "shm.h" #include "util.h" +#include "xmalloc.h" #define TIME_FRAME_RENDERING 0 #define TIME_SCROLL_DAMAGE 0 @@ -43,7 +44,12 @@ static void fdm_hook_refresh_pending_terminals(struct fdm *fdm, void *data); struct renderer * render_init(struct fdm *fdm, struct wayland *wayl) { - struct renderer *renderer = calloc(1, sizeof(*renderer)); + struct renderer *renderer = malloc(sizeof(*renderer)); + if (unlikely(renderer == NULL)) { + LOG_ERRNO("malloc() failed"); + return NULL; + } + *renderer = (struct renderer) { .fdm = fdm, .wayl = wayl, @@ -1691,7 +1697,7 @@ grid_render(struct terminal *term) if (feedback == NULL) { LOG_WARN("failed to create presentation feedback"); } else { - struct presentation_context *ctx = malloc(sizeof(*ctx)); + struct presentation_context *ctx = xmalloc(sizeof(*ctx)); *ctx = (struct presentation_context){ .term = term, .input.tv_sec = term->render.input_time.tv_sec, @@ -1840,7 +1846,7 @@ render_update_title(struct terminal *term) char *copy = NULL; if (strlen(title) > max_len) { - copy = strndup(title, max_len); + copy = xstrndup(title, max_len); title = copy; } |
