postgresql/src/include/utils/palloc.h

39 lines
1.1 KiB
C
Raw Normal View History

/*-------------------------------------------------------------------------
*
* palloc.h
* POSTGRES memory allocator definitions.
*
*
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: palloc.h,v 1.12 2000/01/26 05:58:38 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef PALLOC_H
#define PALLOC_H
#ifdef PALLOC_IS_MALLOC
1999-05-25 12:15:34 -04:00
#define palloc(s) malloc(s)
#define pfree(p) free(p)
#define repalloc(p,s) realloc((p),(s))
1999-05-25 12:15:34 -04:00
#else /* ! PALLOC_IS_MALLOC */
/* ----------
* In the case we use memory contexts, use macro's for palloc() etc.
* ----------
*/
1999-05-25 12:15:34 -04:00
#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)))
1999-05-25 12:15:34 -04:00
#endif /* PALLOC_IS_MALLOC */
/* like strdup except uses palloc */
extern char *pstrdup(const char *pointer);
#endif /* PALLOC_H */