Re: why declare arg as a array in FunctionCallInfoData structure

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Tao Ma <feng_eden(at)163(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: why declare arg as a array in FunctionCallInfoData structure
Date: 2009-02-02 08:33:39
Message-ID: 20090202083339.GA2610@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)svana(dot)org> http://svana.org/kleptog/
> Please line up in a tree and maintain the heap invariant while
> boarding. Thank you for flying nlogn airlines.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2009-02-02 08:39:25 Re: why declare arg as a array in FunctionCallInfoData structure
Previous Message Zdenek Kotala 2009-02-02 07:51:36 Re: foreign_data test fails with non-C locale