PostgreSQL Source Code  git master
tzparser.h File Reference
#include "utils/datetime.h"
Include dependency graph for tzparser.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  tzEntry
 

Typedefs

typedef struct tzEntry tzEntry
 

Functions

TimeZoneAbbrevTableload_tzoffsets (const char *filename)
 

Typedef Documentation

◆ tzEntry

typedef struct tzEntry tzEntry

Function Documentation

◆ load_tzoffsets()

TimeZoneAbbrevTable* load_tzoffsets ( const char *  filename)

Definition at line 447 of file tzparser.c.

448 {
449  TimeZoneAbbrevTable *result = NULL;
450  MemoryContext tmpContext;
451  MemoryContext oldContext;
452  tzEntry *array;
453  int arraysize;
454  int n;
455 
456  /*
457  * Create a temp memory context to work in. This makes it easy to clean
458  * up afterwards.
459  */
461  "TZParserMemory",
463  oldContext = MemoryContextSwitchTo(tmpContext);
464 
465  /* Initialize array at a reasonable size */
466  arraysize = 128;
467  array = (tzEntry *) palloc(arraysize * sizeof(tzEntry));
468 
469  /* Parse the file(s) */
470  n = ParseTzFile(filename, 0, &array, &arraysize, 0);
471 
472  /* If no errors so far, let datetime.c allocate memory & convert format */
473  if (n >= 0)
474  {
475  result = ConvertTimeZoneAbbrevs(array, n);
476  if (!result)
477  GUC_check_errmsg("out of memory");
478  }
479 
480  /* Clean up */
481  MemoryContextSwitchTo(oldContext);
482  MemoryContextDelete(tmpContext);
483 
484  return result;
485 }
TimeZoneAbbrevTable * ConvertTimeZoneAbbrevs(struct tzEntry *abbrevs, int n)
Definition: datetime.c:4873
#define GUC_check_errmsg
Definition: guc.h:443
MemoryContext CurrentMemoryContext
Definition: mcxt.c:143
void MemoryContextDelete(MemoryContext context)
Definition: mcxt.c:454
void * palloc(Size size)
Definition: mcxt.c:1316
#define AllocSetContextCreate
Definition: memutils.h:129
#define ALLOCSET_SMALL_SIZES
Definition: memutils.h:170
static char * filename
Definition: pg_dumpall.c:119
MemoryContextSwitchTo(old_ctx)
static int ParseTzFile(const char *filename, int depth, tzEntry **base, int *arraysize, int n)
Definition: tzparser.c:276

References ALLOCSET_SMALL_SIZES, AllocSetContextCreate, ConvertTimeZoneAbbrevs(), CurrentMemoryContext, filename, GUC_check_errmsg, MemoryContextDelete(), MemoryContextSwitchTo(), palloc(), and ParseTzFile().

Referenced by check_timezone_abbreviations().