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

Commit13cd720

Browse files
committed
Simplify use of AllocSetContextCreate() wrapper macro.
We can allow this macro to accept either abbreviated or non-abbreviatedallocation parameters by making use of __VA_ARGS__. As noted by AndresFreund, it's unlikely that any compiler would have __builtin_constant_pbut not __VA_ARGS__, so this gives up little or no error checking, andit avoids a minor but annoying API break for extensions.With this change, there is no reason for anybody to callAllocSetContextCreateExtended directly, so in HEAD I renamed it toAllocSetContextCreateInternal. It's probably too late for an ABIbreak like that in 11, though.Discussion:https://postgr.es/m/20181012170355.bhxi273skjt6sag4@alap3.anarazel.de
1 parent24a2c43 commit13cd720

File tree

4 files changed

+22
-21
lines changed

4 files changed

+22
-21
lines changed

‎src/backend/access/transam/xact.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,11 +1000,11 @@ AtStart_Memory(void)
10001000
*/
10011001
if (TransactionAbortContext==NULL)
10021002
TransactionAbortContext=
1003-
AllocSetContextCreateExtended(TopMemoryContext,
1004-
"TransactionAbortContext",
1005-
32*1024,
1006-
32*1024,
1007-
32*1024);
1003+
AllocSetContextCreate(TopMemoryContext,
1004+
"TransactionAbortContext",
1005+
32*1024,
1006+
32*1024,
1007+
32*1024);
10081008

10091009
/*
10101010
* We shouldn't have a transaction context already.

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ AllocSetFreeIndex(Size size)
371371

372372

373373
/*
374-
*AllocSetContextCreateExtended
374+
*AllocSetContextCreateInternal
375375
*Create a new AllocSet context.
376376
*
377377
* parent: parent context, or NULL if top-level context
@@ -381,11 +381,13 @@ AllocSetFreeIndex(Size size)
381381
* maxBlockSize: maximum allocation block size
382382
*
383383
* Most callers should abstract the context size parameters using a macro
384-
* such as ALLOCSET_DEFAULT_SIZES. (This is now *required* when going
385-
* through the AllocSetContextCreate macro.)
384+
* such as ALLOCSET_DEFAULT_SIZES.
385+
*
386+
* Note: don't call this directly; go through the wrapper macro
387+
* AllocSetContextCreate.
386388
*/
387389
MemoryContext
388-
AllocSetContextCreateExtended(MemoryContextparent,
390+
AllocSetContextCreateInternal(MemoryContextparent,
389391
constchar*name,
390392
SizeminContextSize,
391393
SizeinitBlockSize,

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,11 @@ MemoryContextInit(void)
119119
* This should be the last step in this function, as elog.c assumes memory
120120
* management works once ErrorContext is non-null.
121121
*/
122-
ErrorContext=AllocSetContextCreateExtended(TopMemoryContext,
123-
"ErrorContext",
124-
8*1024,
125-
8*1024,
126-
8*1024);
122+
ErrorContext=AllocSetContextCreate(TopMemoryContext,
123+
"ErrorContext",
124+
8*1024,
125+
8*1024,
126+
8*1024);
127127
MemoryContextAllowInCriticalSection(ErrorContext, true);
128128
}
129129

‎src/include/utils/memutils.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ extern void MemoryContextCreate(MemoryContext node,
149149
*/
150150

151151
/* aset.c */
152-
externMemoryContextAllocSetContextCreateExtended(MemoryContextparent,
152+
externMemoryContextAllocSetContextCreateInternal(MemoryContextparent,
153153
constchar*name,
154154
SizeminContextSize,
155155
SizeinitBlockSize,
@@ -158,17 +158,16 @@ extern MemoryContext AllocSetContextCreateExtended(MemoryContext parent,
158158
/*
159159
* This wrapper macro exists to check for non-constant strings used as context
160160
* names; that's no longer supported. (Use MemoryContextSetIdentifier if you
161-
* want to provide a variable identifier.) Note you must specify block sizes
162-
* with one of the abstraction macros below.
161+
* want to provide a variable identifier.)
163162
*/
164163
#ifdefHAVE__BUILTIN_CONSTANT_P
165-
#defineAllocSetContextCreate(parent,name,allocparams) \
164+
#defineAllocSetContextCreate(parent,name,...) \
166165
(StaticAssertExpr(__builtin_constant_p(name), \
167166
"memory context names must be constant strings"), \
168-
AllocSetContextCreateExtended(parent, name,allocparams))
167+
AllocSetContextCreateInternal(parent, name,__VA_ARGS__))
169168
#else
170-
#defineAllocSetContextCreate(parent,name,allocparams) \
171-
AllocSetContextCreateExtended(parent, name, allocparams)
169+
#defineAllocSetContextCreate \
170+
AllocSetContextCreateInternal
172171
#endif
173172

174173
/* slab.c */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp