mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-01-12 18:34:36 +08:00
Cleanup for pull-up-isReset patch.
Clear isReset before, not after, calling the context-specific alloc method, so as to preserve the option to do a tail call in MemoryContextAlloc (and also so this code isn't assuming that a failed alloc call won't have changed the context's state before failing). Fix missed direct invocation of reset method. Reformat a comment.
This commit is contained in:
parent
11c08c3fd7
commit
b23aeb6519
@ -128,11 +128,11 @@ typedef void *AllocPointer;
|
|||||||
/*
|
/*
|
||||||
* AllocSetContext is our standard implementation of MemoryContext.
|
* AllocSetContext is our standard implementation of MemoryContext.
|
||||||
*
|
*
|
||||||
* Note: header.isReset means there is nothing for AllocSetReset to do. This is
|
* Note: header.isReset means there is nothing for AllocSetReset to do.
|
||||||
* different from the aset being physically empty (empty blocks list) because
|
* This is different from the aset being physically empty (empty blocks list)
|
||||||
* we may still have a keeper block. It's also different from the set being
|
* because we may still have a keeper block. It's also different from the set
|
||||||
* logically empty, because we don't attempt to detect pfree'ing the last
|
* being logically empty, because we don't attempt to detect pfree'ing the
|
||||||
* active chunk.
|
* last active chunk.
|
||||||
*/
|
*/
|
||||||
typedef struct AllocSetContext
|
typedef struct AllocSetContext
|
||||||
{
|
{
|
||||||
|
@ -234,7 +234,7 @@ MemoryContextResetAndDeleteChildren(MemoryContext context)
|
|||||||
AssertArg(MemoryContextIsValid(context));
|
AssertArg(MemoryContextIsValid(context));
|
||||||
|
|
||||||
MemoryContextDeleteChildren(context);
|
MemoryContextDeleteChildren(context);
|
||||||
(*context->methods->reset) (context);
|
MemoryContextReset(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -510,16 +510,15 @@ MemoryContextCreate(NodeTag tag, Size size,
|
|||||||
void *
|
void *
|
||||||
MemoryContextAlloc(MemoryContext context, Size size)
|
MemoryContextAlloc(MemoryContext context, Size size)
|
||||||
{
|
{
|
||||||
void *ret;
|
|
||||||
AssertArg(MemoryContextIsValid(context));
|
AssertArg(MemoryContextIsValid(context));
|
||||||
|
|
||||||
if (!AllocSizeIsValid(size))
|
if (!AllocSizeIsValid(size))
|
||||||
elog(ERROR, "invalid memory alloc request size %lu",
|
elog(ERROR, "invalid memory alloc request size %lu",
|
||||||
(unsigned long) size);
|
(unsigned long) size);
|
||||||
|
|
||||||
ret = (*context->methods->alloc) (context, size);
|
|
||||||
context->isReset = false;
|
context->isReset = false;
|
||||||
return ret;
|
|
||||||
|
return (*context->methods->alloc) (context, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -540,11 +539,12 @@ MemoryContextAllocZero(MemoryContext context, Size size)
|
|||||||
elog(ERROR, "invalid memory alloc request size %lu",
|
elog(ERROR, "invalid memory alloc request size %lu",
|
||||||
(unsigned long) size);
|
(unsigned long) size);
|
||||||
|
|
||||||
|
context->isReset = false;
|
||||||
|
|
||||||
ret = (*context->methods->alloc) (context, size);
|
ret = (*context->methods->alloc) (context, size);
|
||||||
|
|
||||||
MemSetAligned(ret, 0, size);
|
MemSetAligned(ret, 0, size);
|
||||||
|
|
||||||
context->isReset = false;
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -566,11 +566,12 @@ MemoryContextAllocZeroAligned(MemoryContext context, Size size)
|
|||||||
elog(ERROR, "invalid memory alloc request size %lu",
|
elog(ERROR, "invalid memory alloc request size %lu",
|
||||||
(unsigned long) size);
|
(unsigned long) size);
|
||||||
|
|
||||||
|
context->isReset = false;
|
||||||
|
|
||||||
ret = (*context->methods->alloc) (context, size);
|
ret = (*context->methods->alloc) (context, size);
|
||||||
|
|
||||||
MemSetLoop(ret, 0, size);
|
MemSetLoop(ret, 0, size);
|
||||||
|
|
||||||
context->isReset = false;
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user