diff options
author | Hiltjo Posthuma <hiltjo@codemadness.org> | 2016-03-19 13:03:01 +0100 |
---|---|---|
committer | Hiltjo Posthuma <hiltjo@codemadness.org> | 2016-03-19 13:03:01 +0100 |
commit | 3c79aea2a6bfe7e5256c08e8f762b48d8c58d8e6 (patch) | |
tree | 4f9b6d8448b3393a7857012fa7d4941d291a2154 | |
parent | 3606cc675c8cfed49091421b7197a3667d5d12cb (diff) |
don't use temporary pointer for realloc, it will exit on error
-rw-r--r-- | sfeed.c | 8 |
1 files changed, 3 insertions, 5 deletions
@@ -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--) ; |