Re: Optimize memory allocation code

From: Julien Rouhaud <rjuju123(at)gmail(dot)com>
To: Li Japin <japinli(at)hotmail(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Optimize memory allocation code
Date: 2020-09-26 00:09:31
Message-ID: CAOBaU_ZOe2fjrMF=EXcXc5PNUGpS4s_HgN5=oRNA2Tuim5zHVA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Sat, Sep 26, 2020 at 12:14 AM Li Japin <japinli(at)hotmail(dot)com> wrote:
>
> Hi, hackers!
>
> I find the palloc0() is similar to the palloc(), we can use palloc() inside palloc0()
> to allocate space, thereby I think we can reduce duplication of code.

The code is duplicated on purpose. There's a comment at the beginning
that mentions it:

/* duplicates MemoryContextAllocZero to avoid increased overhead */

Same for MemoryContextAllocZero() itself.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andy Fan 2020-09-26 00:16:52 Re: Dynamic gathering the values for seq_page_cost/xxx_cost
Previous Message David Zhang 2020-09-25 23:39:02 a potential size overflow issue