nodes.c 1.15 KB
Newer Older
1 2
/*-------------------------------------------------------------------------
 *
3
 * nodes.c
4 5
 *	  support code for nodes (now that we get rid of the home-brew
 *	  inheritance system, our support code for nodes get much simpler)
6
 *
Bruce Momjian's avatar
Bruce Momjian committed
7
 * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
Bruce Momjian's avatar
Add:  
Bruce Momjian committed
8
 * Portions Copyright (c) 1994, Regents of the University of California
9 10 11
 *
 *
 * IDENTIFICATION
12
 *	  $Header: /cvsroot/pgsql/src/backend/nodes/nodes.c,v 1.17 2002/10/11 04:16:44 momjian Exp $
13 14
 *
 * HISTORY
15
 *	  Andrew Yu			Oct 20, 1994	file creation
16 17 18 19
 *
 *-------------------------------------------------------------------------
 */
#include "postgres.h"
20
#include "nodes/nodes.h"
21 22 23

/*
 * newNode -
24 25
 *	  create a new node of the specified size and tag the node with the
 *	  specified tag.
26 27
 *
 * !WARNING!: Avoid using newNode directly. You should be using the
28
 *	  macro makeNode. eg. to create a Resdom node, use makeNode(Resdom)
29 30
 *
 */
31 32 33 34
Node *
newNode(Size size, NodeTag tag)
{
	Node	   *newNode;
35

36 37 38 39 40 41 42
	Assert(size >= sizeof(Node));		/* need the tag, at least */

	newNode = (Node *) palloc(size);
	MemSet((char *) newNode, 0, size);
	newNode->type = tag;
	return newNode;
}