aboutsummaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/nodes/nodes.c14
-rw-r--r--src/backend/utils/mmgr/mcxt.c25
2 files changed, 26 insertions, 13 deletions
diff --git a/src/backend/nodes/nodes.c b/src/backend/nodes/nodes.c
index 73c9a1b2b4c..4e694bd09d0 100644
--- a/src/backend/nodes/nodes.c
+++ b/src/backend/nodes/nodes.c
@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/nodes/nodes.c,v 1.15 2002/06/20 20:29:29 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/nodes/nodes.c,v 1.16 2002/10/11 04:12:14 momjian Exp $
*
* HISTORY
* Andrew Yu Oct 20, 1994 file creation
@@ -28,15 +28,5 @@
* macro makeNode. eg. to create a Resdom node, use makeNode(Resdom)
*
*/
-Node *
-newNode(Size size, NodeTag tag)
-{
- Node *newNode;
+Node *newNodeMacroHolder;
- Assert(size >= sizeof(Node)); /* need the tag, at least */
-
- newNode = (Node *) palloc(size);
- MemSet((char *) newNode, 0, size);
- newNode->type = tag;
- return newNode;
-}
diff --git a/src/backend/utils/mmgr/mcxt.c b/src/backend/utils/mmgr/mcxt.c
index 6b77736a3bc..da666076627 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.32 2002/08/12 00:36:12 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/mmgr/mcxt.c,v 1.33 2002/10/11 04:12:14 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.
*/