Skip to content
Snippets Groups Projects
Commit 2177b6b6 authored by Bruce Momjian's avatar Bruce Momjian
Browse files

Oops, back out newNode changes. We are not ready for that yet.

parent 6a7bb0af
No related branches found
No related tags found
No related merge requests found
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/nodes.c,v 1.16 2002/10/11 04:12:14 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/nodes/nodes.c,v 1.17 2002/10/11 04:16:44 momjian Exp $
* *
* HISTORY * HISTORY
* Andrew Yu Oct 20, 1994 file creation * Andrew Yu Oct 20, 1994 file creation
...@@ -28,5 +28,15 @@ ...@@ -28,5 +28,15 @@
* macro makeNode. eg. to create a Resdom node, use makeNode(Resdom) * macro makeNode. eg. to create a Resdom node, use makeNode(Resdom)
* *
*/ */
Node *newNodeMacroHolder; Node *
newNode(Size size, NodeTag tag)
{
Node *newNode;
Assert(size >= sizeof(Node)); /* need the tag, at least */
newNode = (Node *) palloc(size);
MemSet((char *) newNode, 0, size);
newNode->type = tag;
return newNode;
}
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mmgr/mcxt.c,v 1.33 2002/10/11 04:12:14 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/mmgr/mcxt.c,v 1.34 2002/10/11 04:16:44 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -452,29 +452,6 @@ MemoryContextAlloc(MemoryContext context, Size size) ...@@ -452,29 +452,6 @@ MemoryContextAlloc(MemoryContext context, Size size)
return (*context->methods->alloc) (context, size); return (*context->methods->alloc) (context, 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 * pfree
* Release an allocated chunk. * Release an allocated chunk.
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: nodes.h,v 1.119 2002/10/11 04:12:14 momjian Exp $ * $Id: nodes.h,v 1.120 2002/10/11 04:16:44 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -261,24 +261,6 @@ typedef struct Node ...@@ -261,24 +261,6 @@ typedef struct Node
#define nodeTag(nodeptr) (((Node*)(nodeptr))->type) #define nodeTag(nodeptr) (((Node*)(nodeptr))->type)
/*
* There is no way to dereference the palloc'ed pointer to assign the
* tag, and return the pointer itself, so we need a holder variable.
* Fortunately, this function isn't recursive so we just define
* a global variable for this purpose.
*/
extern Node *newNodeMacroHolder;
#define newNode(size, tag) \
( \
AssertMacro((size) >= sizeof(Node)), /* need the tag, at least */ \
\
newNodeMacroHolder = (Node *) palloc0(size), \
newNodeMacroHolder->type = (tag), \
newNodeMacroHolder \
)
#define makeNode(_type_) ((_type_ *) newNode(sizeof(_type_),T_##_type_)) #define makeNode(_type_) ((_type_ *) newNode(sizeof(_type_),T_##_type_))
#define NodeSetTag(nodeptr,t) (((Node*)(nodeptr))->type = (t)) #define NodeSetTag(nodeptr,t) (((Node*)(nodeptr))->type = (t))
...@@ -300,6 +282,11 @@ extern Node *newNodeMacroHolder; ...@@ -300,6 +282,11 @@ extern Node *newNodeMacroHolder;
* ---------------------------------------------------------------- * ----------------------------------------------------------------
*/ */
/*
* nodes/nodes.c
*/
extern Node *newNode(Size size, NodeTag tag);
/* /*
* nodes/{outfuncs.c,print.c} * nodes/{outfuncs.c,print.c}
*/ */
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: palloc.h,v 1.20 2002/10/11 04:12:14 momjian Exp $ * $Id: palloc.h,v 1.21 2002/10/11 04:16:44 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -46,12 +46,9 @@ extern DLLIMPORT MemoryContext CurrentMemoryContext; ...@@ -46,12 +46,9 @@ extern DLLIMPORT MemoryContext CurrentMemoryContext;
* Fundamental memory-allocation operations (more are in utils/memutils.h) * Fundamental memory-allocation operations (more are in utils/memutils.h)
*/ */
extern void *MemoryContextAlloc(MemoryContext context, Size size); extern void *MemoryContextAlloc(MemoryContext context, Size size);
extern void *MemoryContextAllocZero(MemoryContext context, Size size);
#define palloc(sz) MemoryContextAlloc(CurrentMemoryContext, (sz)) #define palloc(sz) MemoryContextAlloc(CurrentMemoryContext, (sz))
#define palloc0(sz) MemoryContextAllocZero(CurrentMemoryContext, (sz))
extern void pfree(void *pointer); extern void pfree(void *pointer);
extern void *repalloc(void *pointer, Size size); extern void *repalloc(void *pointer, Size size);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment