aboutsummaryrefslogtreecommitdiff
path: root/src/include/utils/palloc.h
blob: 9f3a51b42188333c42597fca9f53b598de1a23ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*-------------------------------------------------------------------------
 *
 * palloc.h
 *	  POSTGRES memory allocator definitions.
 *
 *
 * Copyright (c) 1994, Regents of the University of California
 *
 * $Id: palloc.h,v 1.11 2000/01/13 18:26:18 petere Exp $
 *
 *-------------------------------------------------------------------------
 */
#ifndef PALLOC_H
#define PALLOC_H

#ifdef PALLOC_IS_MALLOC

#define palloc(s)	  malloc(s)
#define pfree(p)	  free(p)
#define repalloc(p,s) realloc((p),(s))

#else							/* ! PALLOC_IS_MALLOC */

/* ----------
 * In the case we use memory contexts, use macro's for palloc() etc.
 * ----------
 */
#define palloc(s)	  ((void *)MemoryContextAlloc(CurrentMemoryContext,(Size)(s)))
#define pfree(p)	  MemoryContextFree(CurrentMemoryContext,(Pointer)(p))
#define repalloc(p,s) ((void *)MemoryContextRealloc(CurrentMemoryContext,(Pointer)(p),(Size)(s)))

#endif	 /* PALLOC_IS_MALLOC */

/* like strdup except uses palloc */
extern char *pstrdup(const char *pointer);

#endif	 /* PALLOC_H */