summaryrefslogtreecommitdiff
path: root/src/backend/utils
diff options
context:
space:
mode:
authorBruce Momjian2002-11-10 02:17:25 +0000
committerBruce Momjian2002-11-10 02:17:25 +0000
commit78822b328c2907accf590d5473a0508ea3ee07a5 (patch)
tree69bc6e0445f319311c13b6e8c9865187fbc93d3b /src/backend/utils
parent7aeab94adf2a7e1ad0d0a32ee4bdc6b30e1cadeb (diff)
Add palloc0 function to inline MemSet for newNode call.
Diffstat (limited to 'src/backend/utils')
-rw-r--r--src/backend/utils/mmgr/mcxt.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/backend/utils/mmgr/mcxt.c b/src/backend/utils/mmgr/mcxt.c
index b7dd265863f..d2432c00688 100644
--- a/src/backend/utils/mmgr/mcxt.c
+++ b/src/backend/utils/mmgr/mcxt.c
@@ -14,7 +14,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/mmgr/mcxt.c,v 1.34 2002/10/11 04:16:44 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/mmgr/mcxt.c,v 1.35 2002/11/10 02:17:25 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -453,6 +453,29 @@ MemoryContextAlloc(MemoryContext context, Size size)
}
/*
+ * MemoryContextAllocZero
+ * Like MemoryContextAlloc, but clears allocated memory
+ *
+ * We could just call MemoryContextAlloc then clear the memory, but this
+ * function is called too many times, so we have a separate version.
+ */
+void *
+MemoryContextAllocZero(MemoryContext context, Size size)
+{
+ void *ret;
+
+ AssertArg(MemoryContextIsValid(context));
+
+ if (!AllocSizeIsValid(size))
+ elog(ERROR, "MemoryContextAllocZero: invalid request size %lu",
+ (unsigned long) size);
+
+ ret = (*context->methods->alloc) (context, size);
+ MemSet(ret, 0, size);
+ return ret;
+}
+
+/*
* pfree
* Release an allocated chunk.
*/