Re: Optimize memory allocation code - Mailing list pgsql-hackers

From Julien Rouhaud
Subject Re: Optimize memory allocation code
Date
Msg-id CAOBaU_ZOe2fjrMF=EXcXc5PNUGpS4s_HgN5=oRNA2Tuim5zHVA@mail.gmail.com
Whole thread Raw
In response to Optimize memory allocation code  (Li Japin <japinli@hotmail.com>)
Responses Re: Optimize memory allocation code
List pgsql-hackers
Hi,

On Sat, Sep 26, 2020 at 12:14 AM Li Japin <japinli@hotmail.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.



pgsql-hackers by date:

Previous
From: David Zhang
Date:
Subject: a potential size overflow issue
Next
From: Andy Fan
Date:
Subject: Re: Dynamic gathering the values for seq_page_cost/xxx_cost