palloc.h 1.0 KB
Newer Older
1 2
/*-------------------------------------------------------------------------
 *
3
 * palloc.h
4
 *	  POSTGRES memory allocator definitions.
5 6 7 8
 *
 *
 * Copyright (c) 1994, Regents of the University of California
 *
9
 * $Id: palloc.h,v 1.8 1999/02/13 23:22:26 momjian Exp $
10 11 12
 *
 *-------------------------------------------------------------------------
 */
13
#ifndef PALLOC_H
14 15
#define PALLOC_H

16
#include "c.h"
17

18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
#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.
 * ----------
 */
#  include "utils/mcxt.h"

#  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 */
37 38

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

41
#endif	 /* PALLOC_H */