From 3c79aea2a6bfe7e5256c08e8f762b48d8c58d8e6 Mon Sep 17 00:00:00 2001 From: Hiltjo Posthuma Date: Sat, 19 Mar 2016 13:03:01 +0100 Subject: don't use temporary pointer for realloc, it will exit on error --- sfeed.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/sfeed.c b/sfeed.c index 9112389..96d3940 100644 --- a/sfeed.c +++ b/sfeed.c @@ -204,15 +204,13 @@ string_clear(String *s) static void string_buffer_realloc(String *s, size_t newlen) { - char *p; size_t alloclen; for (alloclen = 64; alloclen <= newlen; alloclen *= 2) ; - if (!(p = realloc(s->data, alloclen))) + if (!(s->data = realloc(s->data, alloclen))) err(1, "realloc"); s->bufsiz = alloclen; - s->data = p; } static void @@ -376,7 +374,7 @@ string_print_encoded(String *s) /* skip leading whitespace */ for (p = s->data; *p && isspace((int)*p); p++) ; - /* seek offset of trailing whitespace */ + /* seek location of trailing whitespace */ for (e = s->data + s->len; e > p && isspace((int)*(e - 1)); e--) ; @@ -407,7 +405,7 @@ string_print_trimmed(String *s) /* skip leading whitespace */ for (p = s->data; *p && isspace((int)*p); p++) ; - /* seek offset of trailing whitespace */ + /* seek location of trailing whitespace */ for (e = s->data + s->len; e > p && isspace((int)*(e - 1)); e--) ; -- cgit v1.2.3