diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2018-10-12 14:26:56 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2018-10-12 14:26:56 -0400 |
commit | 13cd7209f794d9dff8084c9748a78a0a5bf0464a (patch) | |
tree | 871d10a0b651411fd0a4d32bc3a1902264519577 /src/include/utils/memutils.h | |
parent | 24a2c436a5ce1912373a6c9561cbabd09495552d (diff) | |
download | postgresql-13cd7209f794d9dff8084c9748a78a0a5bf0464a.tar.gz postgresql-13cd7209f794d9dff8084c9748a78a0a5bf0464a.zip |
Simplify use of AllocSetContextCreate() wrapper macro.
We can allow this macro to accept either abbreviated or non-abbreviated
allocation parameters by making use of __VA_ARGS__. As noted by Andres
Freund, it's unlikely that any compiler would have __builtin_constant_p
but not __VA_ARGS__, so this gives up little or no error checking, and
it avoids a minor but annoying API break for extensions.
With this change, there is no reason for anybody to call
AllocSetContextCreateExtended directly, so in HEAD I renamed it to
AllocSetContextCreateInternal. It's probably too late for an ABI
break like that in 11, though.
Discussion: https://postgr.es/m/20181012170355.bhxi273skjt6sag4@alap3.anarazel.de
Diffstat (limited to 'src/include/utils/memutils.h')
-rw-r--r-- | src/include/utils/memutils.h | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/include/utils/memutils.h b/src/include/utils/memutils.h index bc5757681ba..d68010f9774 100644 --- a/src/include/utils/memutils.h +++ b/src/include/utils/memutils.h @@ -149,7 +149,7 @@ extern void MemoryContextCreate(MemoryContext node, */ /* aset.c */ -extern MemoryContext AllocSetContextCreateExtended(MemoryContext parent, +extern MemoryContext AllocSetContextCreateInternal(MemoryContext parent, const char *name, Size minContextSize, Size initBlockSize, @@ -158,17 +158,16 @@ extern MemoryContext AllocSetContextCreateExtended(MemoryContext parent, /* * This wrapper macro exists to check for non-constant strings used as context * names; that's no longer supported. (Use MemoryContextSetIdentifier if you - * want to provide a variable identifier.) Note you must specify block sizes - * with one of the abstraction macros below. + * want to provide a variable identifier.) */ #ifdef HAVE__BUILTIN_CONSTANT_P -#define AllocSetContextCreate(parent, name, allocparams) \ +#define AllocSetContextCreate(parent, name, ...) \ (StaticAssertExpr(__builtin_constant_p(name), \ "memory context names must be constant strings"), \ - AllocSetContextCreateExtended(parent, name, allocparams)) + AllocSetContextCreateInternal(parent, name, __VA_ARGS__)) #else -#define AllocSetContextCreate(parent, name, allocparams) \ - AllocSetContextCreateExtended(parent, name, allocparams) +#define AllocSetContextCreate \ + AllocSetContextCreateInternal #endif /* slab.c */ |