MCPcopy Create free account
hub / github.com/eggert/tz / saveabbr

Function saveabbr

zdump.c:354–373  ·  view source on GitHub ↗

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. */

Source from the content-addressed store, hash-verified

352 return the abbreviation. Get the abbreviation from TMP.
353 Exit on memory allocation failure. */
354static char const *
355saveabbr(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
375static void
376close_file(FILE *stream)

Callers 2

mainFunction · 0.85
huntFunction · 0.85

Calls 3

abbrFunction · 0.85
sumsizeFunction · 0.85
xmallocFunction · 0.70

Tested by

no test coverage detected