1996-08-27 21:59:28 -04:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
*
|
1999-02-13 18:22:53 -05:00
|
|
|
* palloc.h
|
1997-09-07 01:04:48 -04:00
|
|
|
* POSTGRES memory allocator definitions.
|
1996-08-27 21:59:28 -04:00
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* Copyright (c) 1994, Regents of the University of California
|
|
|
|
|
*
|
1999-02-13 18:22:53 -05:00
|
|
|
* $Id: palloc.h,v 1.8 1999/02/13 23:22:26 momjian Exp $
|
1996-08-27 21:59:28 -04:00
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
1997-09-07 01:04:48 -04:00
|
|
|
#ifndef PALLOC_H
|
1996-08-27 21:59:28 -04:00
|
|
|
#define PALLOC_H
|
|
|
|
|
|
1999-02-06 11:50:34 -05:00
|
|
|
#include "c.h"
|
1996-11-25 22:20:35 -05:00
|
|
|
|
1999-02-06 11:50:34 -05:00
|
|
|
#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 */
|
1996-08-27 21:59:28 -04:00
|
|
|
|
|
|
|
|
/* like strdup except uses palloc */
|
1997-09-07 22:41:22 -04:00
|
|
|
extern char *pstrdup(char *pointer);
|
1996-08-27 21:59:28 -04:00
|
|
|
|
1998-09-01 00:40:42 -04:00
|
|
|
#endif /* PALLOC_H */
|