summaryrefslogtreecommitdiff
path: root/src/include/utils/palloc.h
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2015-01-30 12:56:48 -0500
committerRobert Haas <rhaas@postgresql.org>2015-01-30 12:56:48 -0500
commitbd4e2fd97d3db84bd970d6051f775b7ff2af0e9d (patch)
tree661eb101e173451f8fe5a2ff7dd3dfac9165c01b /src/include/utils/palloc.h
parent3d660d33aab2f1eb98367a84eb2addf3e0969c05 (diff)
Provide a way to supress the "out of memory" error when allocating.
Using the new interface MemoryContextAllocExtended, callers can specify MCXT_ALLOC_NO_OOM if they are prepared to handle a NULL return value. Michael Paquier, reviewed and somewhat revised by me.
Diffstat (limited to 'src/include/utils/palloc.h')
-rw-r--r--src/include/utils/palloc.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/include/utils/palloc.h b/src/include/utils/palloc.h
index ca03f2b3341..f586fd5535b 100644
--- a/src/include/utils/palloc.h
+++ b/src/include/utils/palloc.h
@@ -43,11 +43,20 @@ typedef struct MemoryContextData *MemoryContext;
extern PGDLLIMPORT MemoryContext CurrentMemoryContext;
/*
+ * Flags for MemoryContextAllocExtended.
+ */
+#define MCXT_ALLOC_HUGE 0x01 /* allow huge allocation (> 1 GB) */
+#define MCXT_ALLOC_NO_OOM 0x02 /* no failure if out-of-memory */
+#define MCXT_ALLOC_ZERO 0x04 /* zero allocated memory */
+
+/*
* Fundamental memory-allocation operations (more are in utils/memutils.h)
*/
extern void *MemoryContextAlloc(MemoryContext context, Size size);
extern void *MemoryContextAllocZero(MemoryContext context, Size size);
extern void *MemoryContextAllocZeroAligned(MemoryContext context, Size size);
+extern void *MemoryContextAllocExtended(MemoryContext context,
+ Size size, int flags);
extern void *palloc(Size size);
extern void *palloc0(Size size);