Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb23aeb6

Browse files
committed
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 havechanged the context's state before failing). Fix missed direct invocationof reset method. Reformat a comment.
1 parent11c08c3 commitb23aeb6

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

‎src/backend/utils/mmgr/aset.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,11 @@ typedef void *AllocPointer;
128128
/*
129129
* AllocSetContext is our standard implementation of MemoryContext.
130130
*
131-
* Note: header.isReset means there is nothing for AllocSetReset to do. This is
132-
* different from the aset being physically empty (empty blocks list) because
133-
* we may still have a keeper block. It's also different from the set being
134-
* logically empty, because we don't attempt to detect pfree'ing the last
135-
* active chunk.
131+
* Note: header.isReset means there is nothing for AllocSetReset to do.
132+
*This isdifferent from the aset being physically empty (empty blocks list)
133+
*becausewe may still have a keeper block. It's also different from the set
134+
*beinglogically empty, because we don't attempt to detect pfree'ing the
135+
*lastactive chunk.
136136
*/
137137
typedefstructAllocSetContext
138138
{

‎src/backend/utils/mmgr/mcxt.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ MemoryContextResetAndDeleteChildren(MemoryContext context)
234234
AssertArg(MemoryContextIsValid(context));
235235

236236
MemoryContextDeleteChildren(context);
237-
(*context->methods->reset)(context);
237+
MemoryContextReset(context);
238238
}
239239

240240
/*
@@ -510,16 +510,15 @@ MemoryContextCreate(NodeTag tag, Size size,
510510
void*
511511
MemoryContextAlloc(MemoryContextcontext,Sizesize)
512512
{
513-
void*ret;
514513
AssertArg(MemoryContextIsValid(context));
515514

516515
if (!AllocSizeIsValid(size))
517516
elog(ERROR,"invalid memory alloc request size %lu",
518517
(unsigned long)size);
519518

520-
ret= (*context->methods->alloc) (context,size);
521519
context->isReset= false;
522-
returnret;
520+
521+
return (*context->methods->alloc) (context,size);
523522
}
524523

525524
/*
@@ -540,11 +539,12 @@ MemoryContextAllocZero(MemoryContext context, Size size)
540539
elog(ERROR,"invalid memory alloc request size %lu",
541540
(unsigned long)size);
542541

542+
context->isReset= false;
543+
543544
ret= (*context->methods->alloc) (context,size);
544545

545546
MemSetAligned(ret,0,size);
546547

547-
context->isReset= false;
548548
returnret;
549549
}
550550

@@ -566,11 +566,12 @@ MemoryContextAllocZeroAligned(MemoryContext context, Size size)
566566
elog(ERROR,"invalid memory alloc request size %lu",
567567
(unsigned long)size);
568568

569+
context->isReset= false;
570+
569571
ret= (*context->methods->alloc) (context,size);
570572

571573
MemSetLoop(ret,0,size);
572574

573-
context->isReset= false;
574575
returnret;
575576
}
576577

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp