aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2011-05-24 17:56:52 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2011-05-24 17:57:32 -0400
commitb23aeb6519651146cf35b2b91d24596f37b40794 (patch)
tree5f1bd4bdffeb9062f3ebcbd6a418ca28158b5e3a /src
parent11c08c3fd79f1fd5a83f9156fc1c43c7be3453ce (diff)
downloadpostgresql-b23aeb6519651146cf35b2b91d24596f37b40794.tar.gz
postgresql-b23aeb6519651146cf35b2b91d24596f37b40794.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/backend/utils/mmgr/aset.c10
-rw-r--r--src/backend/utils/mmgr/mcxt.c13
2 files changed, 12 insertions, 11 deletions
diff --git a/src/backend/utils/mmgr/aset.c b/src/backend/utils/mmgr/aset.c
index 9e321283e59..e202acac934 100644
--- a/src/backend/utils/mmgr/aset.c
+++ b/src/backend/utils/mmgr/aset.c
@@ -128,11 +128,11 @@ typedef void *AllocPointer;
/*
* AllocSetContext is our standard implementation of MemoryContext.
*
- * Note: header.isReset means there is nothing for AllocSetReset to do. This is
- * different from the aset being physically empty (empty blocks list) because
- * we may still have a keeper block. It's also different from the set being
- * logically empty, because we don't attempt to detect pfree'ing the last
- * active chunk.
+ * Note: header.isReset means there is nothing for AllocSetReset to do.
+ * This is different from the aset being physically empty (empty blocks list)
+ * because we may still have a keeper block. It's also different from the set
+ * being logically empty, because we don't attempt to detect pfree'ing the
+ * last active chunk.
*/
typedef struct AllocSetContext
{
diff --git a/src/backend/utils/mmgr/mcxt.c b/src/backend/utils/mmgr/mcxt.c
index 980cce518cf..7ed35d5bdf1 100644
--- a/src/backend/utils/mmgr/mcxt.c
+++ b/src/backend/utils/mmgr/mcxt.c
@@ -234,7 +234,7 @@ MemoryContextResetAndDeleteChildren(MemoryContext context)
AssertArg(MemoryContextIsValid(context));
MemoryContextDeleteChildren(context);
- (*context->methods->reset) (context);
+ MemoryContextReset(context);
}
/*
@@ -510,16 +510,15 @@ MemoryContextCreate(NodeTag tag, Size size,
void *
MemoryContextAlloc(MemoryContext context, Size size)
{
- void *ret;
AssertArg(MemoryContextIsValid(context));
if (!AllocSizeIsValid(size))
elog(ERROR, "invalid memory alloc request size %lu",
(unsigned long) size);
- ret = (*context->methods->alloc) (context, size);
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",
(unsigned long) size);
+ context->isReset = false;
+
ret = (*context->methods->alloc) (context, size);
MemSetAligned(ret, 0, size);
- context->isReset = false;
return ret;
}
@@ -566,11 +566,12 @@ MemoryContextAllocZeroAligned(MemoryContext context, Size size)
elog(ERROR, "invalid memory alloc request size %lu",
(unsigned long) size);
+ context->isReset = false;
+
ret = (*context->methods->alloc) (context, size);
MemSetLoop(ret, 0, size);
- context->isReset = false;
return ret;
}