7
7
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
8
8
* Portions Copyright (c) 1994, Regents of the University of California
9
9
*
10
- * $Id: nodes.h,v 1.121 2002/11/06 00:00:44 tgl Exp $
10
+ * $Id: nodes.h,v 1.122 2002/11/10 02:17:25 momjian Exp $
11
11
*
12
12
*-------------------------------------------------------------------------
13
13
*/
@@ -262,6 +262,24 @@ typedef struct Node
262
262
263
263
#define nodeTag (nodeptr ) (((Node*)(nodeptr))->type)
264
264
265
+ /*
266
+ * There is no way to dereference the palloc'ed pointer to assign the
267
+ * tag, and return the pointer itself, so we need a holder variable.
268
+ * Fortunately, this function isn't recursive so we just define
269
+ * a global variable for this purpose.
270
+ */
271
+ extern Node * newNodeMacroHolder ;
272
+
273
+ #define newNode (size , tag ) \
274
+ ( \
275
+ AssertMacro((size) >= sizeof(Node)), /* need the tag, at least */ \
276
+ \
277
+ newNodeMacroHolder = (Node *) palloc0(size), \
278
+ newNodeMacroHolder->type = (tag), \
279
+ newNodeMacroHolder \
280
+ )
281
+
282
+
265
283
#define makeNode (_type_ ) ((_type_ *) newNode(sizeof(_type_),T_##_type_))
266
284
#define NodeSetTag (nodeptr ,t ) (((Node*)(nodeptr))->type = (t))
267
285
@@ -283,11 +301,6 @@ typedef struct Node
283
301
* ----------------------------------------------------------------
284
302
*/
285
303
286
- /*
287
- * nodes/nodes.c
288
- */
289
- extern Node * newNode (Size size , NodeTag tag );
290
-
291
304
/*
292
305
* nodes/{outfuncs.c,print.c}
293
306
*/
0 commit comments