| 222 | #endif |
| 223 | |
| 224 | static void append(char **base, const char *str) |
| 225 | { |
| 226 | char *oldbase; |
| 227 | char *newbase; |
| 228 | int alloclen; |
| 229 | |
| 230 | oldbase = *base; |
| 231 | if (!oldbase) |
| 232 | { |
| 233 | newbase = strdup(str); |
| 234 | if (!newbase) |
| 235 | { |
| 236 | fprintf(stderr, "ERROR: Failed to strdup %s\n", str); |
| 237 | exit(EXIT_FAILURE); |
| 238 | } |
| 239 | } |
| 240 | else |
| 241 | { |
| 242 | alloclen = strlen(oldbase) + strlen(str) + |
| 243 | sizeof((char) ' ') + sizeof((char) '\0'); |
| 244 | newbase = malloc(alloclen); |
| 245 | if (!newbase) |
| 246 | { |
| 247 | fprintf(stderr, "ERROR: Failed to allocate %d bytes\n", alloclen); |
| 248 | exit(EXIT_FAILURE); |
| 249 | } |
| 250 | |
| 251 | snprintf(newbase, alloclen, "%s %s", oldbase, str); |
| 252 | free(oldbase); |
| 253 | } |
| 254 | |
| 255 | *base = newbase; |
| 256 | } |
| 257 | |
| 258 | static void show_usage(const char *progname, const char *msg, int exitcode) |
| 259 | { |