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

Commit3d05965

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 parent355684e commit3d05965

File tree

4 files changed

+20
-19
lines changed

4 files changed

+20
-19
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,11 +1018,11 @@ AtStart_Memory(void)
10181018
*/
10191019
if (TransactionAbortContext==NULL)
10201020
TransactionAbortContext=
1021-
AllocSetContextCreateExtended(TopMemoryContext,
1022-
"TransactionAbortContext",
1023-
32*1024,
1024-
32*1024,
1025-
32*1024);
1021+
AllocSetContextCreate(TopMemoryContext,
1022+
"TransactionAbortContext",
1023+
32*1024,
1024+
32*1024,
1025+
32*1024);
10261026

10271027
/*
10281028
* We shouldn't have a transaction context already.

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,8 +381,10 @@ 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
388390
AllocSetContextCreateExtended(MemoryContextparent,

‎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
@@ -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
*/
164-
#ifdefHAVE__BUILTIN_CONSTANT_P
165-
#defineAllocSetContextCreate(parent,name,allocparams) \
163+
#if defined(HAVE__BUILTIN_CONSTANT_P)&& defined(HAVE__VA_ARGS)
164+
#defineAllocSetContextCreate(parent,name,...) \
166165
(StaticAssertExpr(__builtin_constant_p(name), \
167166
"memory context names must be constant strings"), \
168-
AllocSetContextCreateExtended(parent, name,allocparams))
167+
AllocSetContextCreateExtended(parent, name,__VA_ARGS__))
169168
#else
170-
#defineAllocSetContextCreate(parent,name,allocparams) \
171-
AllocSetContextCreateExtended(parent, name, allocparams)
169+
#defineAllocSetContextCreate \
170+
AllocSetContextCreateExtended
172171
#endif
173172

174173
/* slab.c */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp