Update FSM on WAL replay. This is a bit limited; the FSM is only updated
[PostgreSQL.git] / src / timezone / ialloc.c
blobc72c9525f1fd77f221290188933d257e832644c9
1 /*
2 * This file is in the public domain, so clarified as of
3 * 2006-07-17 by Arthur David Olson.
5 * IDENTIFICATION
6 * $PostgreSQL$
7 */
9 #include "postgres_fe.h"
11 #include "private.h"
14 #define nonzero(n) (((n) == 0) ? 1 : (n))
16 char *
17 imalloc(int n)
19 return malloc((size_t) nonzero(n));
22 char *
23 icalloc(int nelem, int elsize)
25 if (nelem == 0 || elsize == 0)
26 nelem = elsize = 1;
27 return calloc((size_t) nelem, (size_t) elsize);
30 void *
31 irealloc(void *pointer, int size)
33 if (pointer == NULL)
34 return imalloc(size);
35 return realloc((void *) pointer, (size_t) nonzero(size));
38 char *
39 icatalloc(char *old, const char *new)
41 char *result;
42 int oldsize,
43 newsize;
45 newsize = (new == NULL) ? 0 : strlen(new);
46 if (old == NULL)
47 oldsize = 0;
48 else if (newsize == 0)
49 return old;
50 else
51 oldsize = strlen(old);
52 if ((result = irealloc(old, oldsize + newsize + 1)) != NULL)
53 if (new != NULL)
54 (void) strcpy(result + oldsize, new);
55 return result;
58 char *
59 icpyalloc(const char *string)
61 return icatalloc((char *) NULL, string);
64 void
65 ifree(char *p)
67 if (p != NULL)
68 (void) free(p);
71 void
72 icfree(char *p)
74 if (p != NULL)
75 (void) free(p);