All callers ignore failure anyway, so let's do that internally.
if (!ans)
return -ENOMEM;
- (void) str_realloc(&ans);
+ ans = str_realloc(ans);
*line = TAKE_PTR(ans);
return 0;
}
return (uint8_t*) p + n;
}
-static inline char* str_realloc(char **p) {
- /* Reallocate *p to actual size */
+static inline char* str_realloc(char *p) {
+ /* Reallocate *p to actual size. Ignore failure, and return the original string on error. */
- if (!*p)
+ if (!p)
return NULL;
- char *t = realloc(*p, strlen(*p) + 1);
- if (!t)
- return NULL;
-
- return (*p = t);
+ return realloc(p, strlen(p) + 1) ?: p;
}
char* string_erase(char *x);
}
*s = '\0';
- (void) str_realloc(&p);
- return p;
+ return str_realloc(p);
}
static int utf8_char_console_width(const char *str) {
finish:
*s = '\0';
- (void) str_realloc(&p);
- return p;
+ return str_realloc(p);
}
char *ascii_is_valid(const char *str) {