Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 2177b6b

Browse files
committed
Oops, back out newNode changes. We are not ready for that yet.
1 parent 6a7bb0a commit 2177b6b

File tree

4 files changed

+20
-49
lines changed

4 files changed

+20
-49
lines changed

src/backend/nodes/nodes.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/nodes/nodes.c,v 1.16 2002/10/11 04:12:14 momjian Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/nodes/nodes.c,v 1.17 2002/10/11 04:16:44 momjian Exp $
1313
*
1414
* HISTORY
1515
* Andrew Yu Oct 20, 1994 file creation
@@ -28,5 +28,15 @@
2828
* macro makeNode. eg. to create a Resdom node, use makeNode(Resdom)
2929
*
3030
*/
31-
Node *newNodeMacroHolder;
31+
Node *
32+
newNode(Size size, NodeTag tag)
33+
{
34+
Node *newNode;
3235

36+
Assert(size >= sizeof(Node)); /* need the tag, at least */
37+
38+
newNode = (Node *) palloc(size);
39+
MemSet((char *) newNode, 0, size);
40+
newNode->type = tag;
41+
return newNode;
42+
}

src/backend/utils/mmgr/mcxt.c

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*
1515
*
1616
* IDENTIFICATION
17-
* $Header: /cvsroot/pgsql/src/backend/utils/mmgr/mcxt.c,v 1.33 2002/10/11 04:12:14 momjian Exp $
17+
* $Header: /cvsroot/pgsql/src/backend/utils/mmgr/mcxt.c,v 1.34 2002/10/11 04:16:44 momjian Exp $
1818
*
1919
*-------------------------------------------------------------------------
2020
*/
@@ -452,29 +452,6 @@ MemoryContextAlloc(MemoryContext context, Size size)
452452
return (*context->methods->alloc) (context, size);
453453
}
454454

455-
/*
456-
* MemoryContextAllocZero
457-
* Like MemoryContextAlloc, but clears allocated memory
458-
*
459-
* We could just call MemoryContextAlloc then clear the memory, but this
460-
* function is called too many times, so we have a separate version.
461-
*/
462-
void *
463-
MemoryContextAllocZero(MemoryContext context, Size size)
464-
{
465-
void *ret;
466-
467-
AssertArg(MemoryContextIsValid(context));
468-
469-
if (!AllocSizeIsValid(size))
470-
elog(ERROR, "MemoryContextAllocZero: invalid request size %lu",
471-
(unsigned long) size);
472-
473-
ret = (*context->methods->alloc) (context, size);
474-
MemSet(ret, 0, size);
475-
return ret;
476-
}
477-
478455
/*
479456
* pfree
480457
* Release an allocated chunk.

src/include/nodes/nodes.h

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: nodes.h,v 1.119 2002/10/11 04:12:14 momjian Exp $
10+
* $Id: nodes.h,v 1.120 2002/10/11 04:16:44 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -261,24 +261,6 @@ typedef struct Node
261261

262262
#define nodeTag(nodeptr) (((Node*)(nodeptr))->type)
263263

264-
/*
265-
* There is no way to dereference the palloc'ed pointer to assign the
266-
* tag, and return the pointer itself, so we need a holder variable.
267-
* Fortunately, this function isn't recursive so we just define
268-
* a global variable for this purpose.
269-
*/
270-
extern Node *newNodeMacroHolder;
271-
272-
#define newNode(size, tag) \
273-
( \
274-
AssertMacro((size) >= sizeof(Node)), /* need the tag, at least */ \
275-
\
276-
newNodeMacroHolder = (Node *) palloc0(size), \
277-
newNodeMacroHolder->type = (tag), \
278-
newNodeMacroHolder \
279-
)
280-
281-
282264
#define makeNode(_type_) ((_type_ *) newNode(sizeof(_type_),T_##_type_))
283265
#define NodeSetTag(nodeptr,t) (((Node*)(nodeptr))->type = (t))
284266

@@ -300,6 +282,11 @@ extern Node *newNodeMacroHolder;
300282
* ----------------------------------------------------------------
301283
*/
302284

285+
/*
286+
* nodes/nodes.c
287+
*/
288+
extern Node *newNode(Size size, NodeTag tag);
289+
303290
/*
304291
* nodes/{outfuncs.c,print.c}
305292
*/

src/include/utils/palloc.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
2222
* Portions Copyright (c) 1994, Regents of the University of California
2323
*
24-
* $Id: palloc.h,v 1.20 2002/10/11 04:12:14 momjian Exp $
24+
* $Id: palloc.h,v 1.21 2002/10/11 04:16:44 momjian Exp $
2525
*
2626
*-------------------------------------------------------------------------
2727
*/
@@ -46,12 +46,9 @@ extern DLLIMPORT MemoryContext CurrentMemoryContext;
4646
* Fundamental memory-allocation operations (more are in utils/memutils.h)
4747
*/
4848
extern void *MemoryContextAlloc(MemoryContext context, Size size);
49-
extern void *MemoryContextAllocZero(MemoryContext context, Size size);
5049

5150
#define palloc(sz) MemoryContextAlloc(CurrentMemoryContext, (sz))
5251

53-
#define palloc0(sz) MemoryContextAllocZero(CurrentMemoryContext, (sz))
54-
5552
extern void pfree(void *pointer);
5653

5754
extern void *repalloc(void *pointer, Size size);

0 commit comments

Comments
 (0)