Re: Avoid use deprecated Windows Memory API
От | Aleksander Alekseev |
---|---|
Тема | Re: Avoid use deprecated Windows Memory API |
Дата | |
Msg-id | CAJ7c6TPzD4VsmpeYVT=kOyimMA0u59BztmhOunWxMcrjgsn1jg@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: Avoid use deprecated Windows Memory API (Alvaro Herrera <alvherre@alvh.no-ip.org>) |
Ответы |
Re: Avoid use deprecated Windows Memory API
Re: Avoid use deprecated Windows Memory API |
Список | pgsql-hackers |
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. 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. > 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. [1]: https://docs.microsoft.com/en-us/windows/win32/api/securitybaseapi/nf-securitybaseapi-initializeacl [2]: https://docs.microsoft.com/en-us/windows/win32/api/securitybaseapi/nf-securitybaseapi-gettokeninformation -- Best regards, Aleksander Alekseev
Вложения
В списке pgsql-hackers по дате отправления: