+static void nl_append_string(char * append, char ** string)
+{
+ char * err = "too large sizes";
+ exit_trouble(UINT32_MAX < strlen(append), __func__, err);
+ uint32_t new_size = strlen(append);
+ uint32_t old_size = 0;
+ uint8_t add_nl = 0;
+ if (*string)
+ {
+ exit_trouble(UINT32_MAX < new_size + strlen(*string), __func__, err);
+ old_size = strlen(*string);
+ add_nl = 1;
+ }
+ char * new_string = try_malloc(old_size + add_nl + new_size + 1, __func__);
+ memcpy(new_string, *string, old_size);
+ char * pattern = add_nl ? "\n%s" : "%s";
+ int test = sprintf(new_string + old_size, pattern, append);
+ exit_trouble(test < 0, __func__, "sprintf");
+ free(*string);
+ *string = new_string;
+}
+
+
+