1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-22 21:53:06 +03:00

Prevent tv_sec from becoming negative in connection timeout code.

This commit is contained in:
Bruce Momjian
2002-10-11 04:12:14 +00:00
parent c2311337f0
commit 6a7bb0afbc
6 changed files with 68 additions and 27 deletions

View File

@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/nodes.c,v 1.15 2002/06/20 20:29:29 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/nodes.c,v 1.16 2002/10/11 04:12:14 momjian Exp $
*
* HISTORY
* Andrew Yu Oct 20, 1994 file creation
@@ -28,15 +28,5 @@
* macro makeNode. eg. to create a Resdom node, use makeNode(Resdom)
*
*/
Node *
newNode(Size size, NodeTag tag)
{
Node *newNode;
Node *newNodeMacroHolder;
Assert(size >= sizeof(Node)); /* need the tag, at least */
newNode = (Node *) palloc(size);
MemSet((char *) newNode, 0, size);
newNode->type = tag;
return newNode;
}

View File

@@ -14,7 +14,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mmgr/mcxt.c,v 1.32 2002/08/12 00:36:12 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/mmgr/mcxt.c,v 1.33 2002/10/11 04:12:14 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -452,6 +452,29 @@ MemoryContextAlloc(MemoryContext context, Size 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
* Release an allocated chunk.