From e4c527b0f07b91fb3cd9ba58ba057dfea9da9356 Mon Sep 17 00:00:00 2001 From: KatolaZ Date: Fri, 9 Aug 2019 09:20:53 +0100 Subject: check all mem allocations --- lineset.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'lineset.c') diff --git a/lineset.c b/lineset.c index 47c3de4..7a244e5 100644 --- a/lineset.c +++ b/lineset.c @@ -12,9 +12,9 @@ void ensure_line_length(line_t *l, int len){ if (l->sz < len + 1){ tmp = realloc(l->s, (len+1) * 2 * sizeof(char)); - if (!tmp){ + if (tmp == NULL){ fprintf(stderr, "Unable to allocate string\n"); - cleanup(-1); + cleanup(1); } l->s = tmp; l->sz = (len + 1) * 2; @@ -29,7 +29,7 @@ void alloc_line(line_t *l){ tmp = malloc((l->sz) * sizeof(char)); if (tmp == NULL){ fprintf(stderr, "unable to allocate line\n"); - cleanup(-1); + cleanup(1); } l->s = tmp; memset(l->s, BG, l->sz); @@ -46,7 +46,7 @@ void ensure_num_lines(lineset_t *ls, int n){ tmp = realloc(ls->l, (n + LONG_STEP) * sizeof(line_t)); if (tmp == NULL){ fprintf(stderr, "Unable to allocate memory for more lines"); - cleanup(-1); + cleanup(1); } else { ls->l = tmp; @@ -147,7 +147,7 @@ void copy_lines_to_ring(int y1, int y2, int which){ tmp = realloc(undo, (undo_sz + 10) * sizeof(lineset_t)); if (tmp == NULL){ fprintf(stderr, "Error allocating undo buffer"); - cleanup(-1); + cleanup(1); } undo = tmp; for (i=0; i<10; i++){ -- cgit v1.2.3