mirror of
				https://github.com/postgres/postgres.git
				synced 2025-11-03 09:13:20 +03:00 
			
		
		
		
	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
This commit is contained in:
		@@ -1000,11 +1000,11 @@ AtStart_Memory(void)
 | 
			
		||||
	 */
 | 
			
		||||
	if (TransactionAbortContext == NULL)
 | 
			
		||||
		TransactionAbortContext =
 | 
			
		||||
			AllocSetContextCreateExtended(TopMemoryContext,
 | 
			
		||||
										  "TransactionAbortContext",
 | 
			
		||||
										  32 * 1024,
 | 
			
		||||
										  32 * 1024,
 | 
			
		||||
										  32 * 1024);
 | 
			
		||||
			AllocSetContextCreate(TopMemoryContext,
 | 
			
		||||
								  "TransactionAbortContext",
 | 
			
		||||
								  32 * 1024,
 | 
			
		||||
								  32 * 1024,
 | 
			
		||||
								  32 * 1024);
 | 
			
		||||
 | 
			
		||||
	/*
 | 
			
		||||
	 * We shouldn't have a transaction context already.
 | 
			
		||||
 
 | 
			
		||||
@@ -371,7 +371,7 @@ AllocSetFreeIndex(Size size)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * AllocSetContextCreateExtended
 | 
			
		||||
 * AllocSetContextCreateInternal
 | 
			
		||||
 *		Create a new AllocSet context.
 | 
			
		||||
 *
 | 
			
		||||
 * parent: parent context, or NULL if top-level context
 | 
			
		||||
@@ -381,11 +381,13 @@ AllocSetFreeIndex(Size size)
 | 
			
		||||
 * maxBlockSize: maximum allocation block size
 | 
			
		||||
 *
 | 
			
		||||
 * Most callers should abstract the context size parameters using a macro
 | 
			
		||||
 * such as ALLOCSET_DEFAULT_SIZES.  (This is now *required* when going
 | 
			
		||||
 * through the AllocSetContextCreate macro.)
 | 
			
		||||
 * such as ALLOCSET_DEFAULT_SIZES.
 | 
			
		||||
 *
 | 
			
		||||
 * Note: don't call this directly; go through the wrapper macro
 | 
			
		||||
 * AllocSetContextCreate.
 | 
			
		||||
 */
 | 
			
		||||
MemoryContext
 | 
			
		||||
AllocSetContextCreateExtended(MemoryContext parent,
 | 
			
		||||
AllocSetContextCreateInternal(MemoryContext parent,
 | 
			
		||||
							  const char *name,
 | 
			
		||||
							  Size minContextSize,
 | 
			
		||||
							  Size initBlockSize,
 | 
			
		||||
 
 | 
			
		||||
@@ -119,11 +119,11 @@ MemoryContextInit(void)
 | 
			
		||||
	 * This should be the last step in this function, as elog.c assumes memory
 | 
			
		||||
	 * management works once ErrorContext is non-null.
 | 
			
		||||
	 */
 | 
			
		||||
	ErrorContext = AllocSetContextCreateExtended(TopMemoryContext,
 | 
			
		||||
												 "ErrorContext",
 | 
			
		||||
												 8 * 1024,
 | 
			
		||||
												 8 * 1024,
 | 
			
		||||
												 8 * 1024);
 | 
			
		||||
	ErrorContext = AllocSetContextCreate(TopMemoryContext,
 | 
			
		||||
										 "ErrorContext",
 | 
			
		||||
										 8 * 1024,
 | 
			
		||||
										 8 * 1024,
 | 
			
		||||
										 8 * 1024);
 | 
			
		||||
	MemoryContextAllowInCriticalSection(ErrorContext, true);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user