Re: [PATCH 2/7] regedit: Use a helper function to allocate memory and check for a valid pointer
Hugh McMaster <hugh.mcmaster(a)outlook.com> writes:
+static void *heap_alloc(size_t size) +{ + void *buf; + + if (!(buf = HeapAlloc(GetProcessHeap(), 0, size))) + { + ERR("Out of memory!\n"); + exit(1); + } + + return buf; +}
That's not the standard heap_alloc(), so a different name would be preferable. I'd suggest heap_xalloc by analogy with xmalloc. -- Alexandre Julliard julliard(a)winehq.org
On Thursday, 27 July 2017 2:41 AM, Alexandre Julliard wrote:
That's not the standard heap_alloc(), so a different name would be preferable. I'd suggest heap_xalloc by analogy with xmalloc.
"Standard" would be a function just returning HeapAlloc(...), right? And you did mention the 'x' prefix a few days ago. Totally missed that in the patch. By the way, regedit should exit(0), but perhaps exit(1) - as in the patch - is still more appropriate for allocation failure? Thanks for the help.
Hugh McMaster <hugh.mcmaster(a)outlook.com> writes:
On Thursday, 27 July 2017 2:41 AM, Alexandre Julliard wrote:
That's not the standard heap_alloc(), so a different name would be preferable. I'd suggest heap_xalloc by analogy with xmalloc.
"Standard" would be a function just returning HeapAlloc(...), right?
Yes, the one that we use in many places, and that Michael is going to move to a global header any day now ;-)
By the way, regedit should exit(0), but perhaps exit(1) - as in the patch - is still more appropriate for allocation failure?
Sure. -- Alexandre Julliard julliard(a)winehq.org
participants (2)
-
Alexandre Julliard -
Hugh McMaster