diff options
author | Bruce Momjian <bruce@momjian.us> | 2002-10-11 04:12:14 +0000 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 2002-10-11 04:12:14 +0000 |
commit | 6a7bb0afbcab1ac3f1e9bbcb536bc7865f4503e6 (patch) | |
tree | 9fec5490cf4e27e39e37695f0226735a8ed7269c /src/include | |
parent | c2311337f0bff953e60e8f65e759de041e4f2bc4 (diff) |
Prevent tv_sec from becoming negative in connection timeout code.
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/nodes/nodes.h | 25 | ||||
-rw-r--r-- | src/include/utils/palloc.h | 5 |
2 files changed, 23 insertions, 7 deletions
diff --git a/src/include/nodes/nodes.h b/src/include/nodes/nodes.h index ee472203e68..4b6a3c04eb5 100644 --- a/src/include/nodes/nodes.h +++ b/src/include/nodes/nodes.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: nodes.h,v 1.118 2002/08/31 22:10:47 tgl Exp $ + * $Id: nodes.h,v 1.119 2002/10/11 04:12:14 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -261,6 +261,24 @@ typedef struct Node #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 NodeSetTag(nodeptr,t) (((Node*)(nodeptr))->type = (t)) @@ -283,11 +301,6 @@ typedef struct Node */ /* - * nodes/nodes.c - */ -extern Node *newNode(Size size, NodeTag tag); - -/* * nodes/{outfuncs.c,print.c} */ extern char *nodeToString(void *obj); diff --git a/src/include/utils/palloc.h b/src/include/utils/palloc.h index 168ed301977..c1cb6f69c42 100644 --- a/src/include/utils/palloc.h +++ b/src/include/utils/palloc.h @@ -21,7 +21,7 @@ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: palloc.h,v 1.19 2002/06/20 20:29:53 momjian Exp $ + * $Id: palloc.h,v 1.20 2002/10/11 04:12:14 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -46,9 +46,12 @@ extern DLLIMPORT MemoryContext CurrentMemoryContext; * Fundamental memory-allocation operations (more are in utils/memutils.h) */ extern void *MemoryContextAlloc(MemoryContext context, Size size); +extern void *MemoryContextAllocZero(MemoryContext context, Size size); #define palloc(sz) MemoryContextAlloc(CurrentMemoryContext, (sz)) +#define palloc0(sz) MemoryContextAllocZero(CurrentMemoryContext, (sz)) + extern void pfree(void *pointer); extern void *repalloc(void *pointer, Size size); |