Re: why declare arg as a array in FunctionCallInfoData structure - Mailing list pgsql-hackers

From Martijn van Oosterhout
Subject Re: why declare arg as a array in FunctionCallInfoData structure
Date
Msg-id 20090202083339.GA2610@svana.org
Whole thread Raw
In response to why declare arg as a array in FunctionCallInfoData structure  ("Tao Ma" <feng_eden@163.com>)
List pgsql-hackers
On Mon, Feb 02, 2009 at 03:16:01PM +0800, Tao Ma wrote:
> hi,
>
> When I read the postgresql codes, I noticed that the FunctionCallInfoData
> structure(declared in the src/include/fmgr.h) contains two arrays 'arg' and
> 'argnull'.
> Why don't you declare it as a pointer and allocate the memory from heap? It
> saves more momery if 'arg' and 'argnull' declares as pointer type.

I imagaine it's because most of the time this structure would be
allocated on the stack, where allocation is essentially free. Having to
allocate two arrays from the heap would be slower.

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Please line up in a tree and maintain the heap invariant while
> boarding. Thank you for flying nlogn airlines.

pgsql-hackers by date:

Previous
From: "Tao Ma"
Date:
Subject: why declare arg as a array in FunctionCallInfoData structure
Next
From: Pavel Stehule
Date:
Subject: Re: why declare arg as a array in FunctionCallInfoData structure