Return a time zone abbreviation. If the abbreviation needs to be saved, use *BUF (of size *BUFALLOC) to save it, and return the abbreviation in the possibly reallocated *BUF. Otherwise, just return the abbreviation. Get the abbreviation from TMP. Exit on memory allocation failure. */
| 352 | return the abbreviation. Get the abbreviation from TMP. |
| 353 | Exit on memory allocation failure. */ |
| 354 | static char const * |
| 355 | saveabbr(char **buf, ptrdiff_t *bufalloc, struct tm const *tmp) |
| 356 | { |
| 357 | char const *ab = abbr(tmp); |
| 358 | if (HAVE_LOCALTIME_RZ) |
| 359 | return ab; |
| 360 | else { |
| 361 | ptrdiff_t absize = strlen(ab) + 1; |
| 362 | if (*bufalloc < absize) { |
| 363 | free(*buf); |
| 364 | |
| 365 | /* Make the new buffer at least twice as long as the old, |
| 366 | to avoid O(N**2) behavior on repeated calls. */ |
| 367 | *bufalloc = sumsize(*bufalloc, absize); |
| 368 | |
| 369 | *buf = xmalloc(*bufalloc); |
| 370 | } |
| 371 | return strcpy(*buf, ab); |
| 372 | } |
| 373 | } |
| 374 | |
| 375 | static void |
| 376 | close_file(FILE *stream) |