src/backend/utils/mmgr/mcxt.c
void *
MemoryContextAlloc(MemoryContext context, Size size)
{
	void	   *ret;

	AssertArg(MemoryContextIsValid(context));
	AssertNotInCriticalSection(context);

	if (!AllocSizeIsValid(size))
		elog(ERROR, "invalid memory alloc request size %zu", size);

	context->isReset = false;

	ret = context->methods->alloc(context, size);
	if (unlikely(ret == NULL))
	{
		MemoryContextStats(TopMemoryContext);

		/*
		 * Here, and elsewhere in this module, we show the target context's
		 * "name" but not its "ident" (if any) in user-visible error messages.
		 * The "ident" string might contain security-sensitive data, such as
		 * values in SQL commands.
		 */
		ereport(ERROR,
				(errcode(ERRCODE_OUT_OF_MEMORY),
				 errmsg("out of memory"),
				 errdetail("Failed on request of size %zu in memory context \"%s\".",
						   size, context->name)));
	}

	VALGRIND_MEMPOOL_ALLOC(context, ret, size);

	return ret;
}
/*
 * MemoryContextAlloc
 *		Allocate space within the specified context.
 *
 * This could be turned into a macro, but we'd have to import
 * nodes/memnodes.h into postgres.h which seems a bad idea.
 */
MemoryContextAlloc
Allocate space within the specified context.

This could be turned into a macro, but we'd have to import
nodes/memnodes.h into postgres.h which seems a bad idea.
MemoryContextAlloc Allocate space within the specified context . This could be turned into a macro but we ' d have to import nodes / memnodes . h into postgres . h which seems a bad idea .
void *
MemoryContextAlloc(MemoryContext context, Size size)
{
	void	   *ret;
	AssertArg(MemoryContextIsValid(context));
	AssertNotInCriticalSection(context);
	if (!AllocSizeIsValid(size))
		elog(ERROR, "invalid memory alloc request size %zu", size);
	context->isReset = false;
	ret = context->methods->alloc(context, size);
	if (unlikely(ret == NULL))
	{
		MemoryContextStats(TopMemoryContext);
		ereport(ERROR,
				(errcode(ERRCODE_OUT_OF_MEMORY),
				 errmsg("out of memory"),
				 errdetail("Failed on request of size %zu in memory context \"%s\".",
						   size, context->name)));
	}
	VALGRIND_MEMPOOL_ALLOC(context, ret, size);
	return ret;
}
void * MemoryContextAlloc ( MemoryContext context , Size size ) { void * ret ; AssertArg ( MemoryContextIsValid ( context ) ) ; AssertNotInCriticalSection ( context ) ; if ( ! AllocSizeIsValid ( size ) ) elog ( ERROR , " " , size ) ; context -> isReset = false ; ret = context -> methods -> alloc ( context , size ) ; if ( unlikely ( ret == NULL ) ) { MemoryContextStats ( TopMemoryContext ) ; ereport ( ERROR , ( errcode ( ERRCODE_OUT_OF_MEMORY ) , errmsg ( " " ) , errdetail ( " \" \" " , size , context -> name ) ) ) ; } VALGRIND_MEMPOOL_ALLOC ( context , ret , size ) ; return ret ; }
MemoryContextAlloc
              Allocate space within the specified context.
MemoryContextAlloc Allocate space within the specified context .
/*
		 * Here, and elsewhere in this module, we show the target context's
		 * "name" but not its "ident" (if any) in user-visible error messages.
		 * The "ident" string might contain security-sensitive data, such as
		 * values in SQL commands.
		 */