src/backend/utils/mmgr/mcxt.c
void *
MemoryContextAllocZero(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);

	MemSetAligned(ret, 0, size);

	return ret;
}
/*
 * MemoryContextAllocZero
 *		Like MemoryContextAlloc, but clears allocated memory
 *
 *	We could just call MemoryContextAlloc then clear the memory, but this
 *	is a very common combination, so we provide the combined operation.
 */
MemoryContextAllocZero
Like MemoryContextAlloc, but clears allocated memory

We could just call MemoryContextAlloc then clear the memory, but this
is a very common combination, so we provide the combined operation.
MemoryContextAllocZero Like MemoryContextAlloc but clears allocated memory We could just call MemoryContextAlloc then clear the memory but this is a very common combination so we provide the combined operation .
void *
MemoryContextAllocZero(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);
	MemSetAligned(ret, 0, size);
	return ret;
}
void * MemoryContextAllocZero ( 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 ) ; MemSetAligned ( ret , 0 , size ) ; return ret ; }
MemoryContextAllocZero
              Like MemoryContextAlloc, but clears allocated memory
MemoryContextAllocZero Like MemoryContextAlloc but clears allocated memory