Re: Avoid use deprecated Windows Memory API

From: Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>
To: Aleksander Alekseev <aleksander(at)timescale(dot)com>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Daniel Gustafsson <daniel(at)yesql(dot)se>
Subject: Re: Avoid use deprecated Windows Memory API
Date: 2022-09-15 13:05:19
Message-ID: CAEudQAp57HtShUY3wiw-k3DROx9Ncm4JbbHJAUEpWQydAQB1+w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Em qui., 15 de set. de 2022 às 09:58, Aleksander Alekseev <
aleksander(at)timescale(dot)com> escreveu:

> Hi Ranier,
>
> > use HeapAlloc instead, once LocalAlloc is an overhead wrapper to
> HeapAlloc.
>
> Thanks for the patch.
>
> Although MSDN doesn't explicitly say that LocalAlloc is _depricated_
> +1 for replacing it.

The MSDN says:
" New applications should use the heap functions
<https://docs.microsoft.com/en-us/windows/desktop/Memory/heap-functions>".
IMO Postgres 16, fits here.

I agree with Alvaro that it is unlikely to be
> ever removed, but this is a trivial change, so let's keep the code a
> bit cleaner. Also I agree that no benchmarking is required for this
> patch since the code is not performance-sensitive.
>
In no time, the patch claims performance.
So much so that the open CF is in refactoring.

> > These calls are not equal, the LocalAlloc calls zeroes out the allocated
> memory
>
> I took a look. The memory is initialized below by InitializeAcl() /
> GetTokenInformation() [1][2] so it seems we are fine here.
>
> The patch didn't have a proper commit message and had some issues with
> the formating. I fixed this. The new code checks the return value of
> GetProcessHeap() which is unlikely to fail, so I figured unlikely() is
> appropriate:
>
> + hDefaultProcessHeap = GetProcessHeap();
> + if (unlikely(hDefaultProcessHeap == NULL))
>
> The corrected patch is attached.
>
Thanks for the review and fixes.

regards,
Ranier Vilela

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2022-09-15 13:08:21 Re: pgsql: Doc: Explain about Column List feature.
Previous Message Aleksander Alekseev 2022-09-15 12:58:40 Re: Avoid use deprecated Windows Memory API