Subject: Re: bug#33847: 27.0.50; emacsclient does not find server socket

From: Eli Zaretskii <[email-masked]>
Date: Sun, 25 Jul 2021 10:27:43 +0300

> Cc: [email-masked], [email-masked], [email-masked], [email-masked]
> From: Paul Eggert <[email-masked]>
> Date: Sat, 24 Jul 2021 16:31:21 -0700
> 
> From 4f8392f633cbd3b978c05b972983cfef82be4e7b Mon Sep 17 00:00:00 2001
> From: Paul Eggert <[email-masked]>
> Date: Sat, 24 Jul 2021 16:11:16 -0700
> Subject: [PATCH 4/4] Port recent Gnulib changes to MS-Windows
> MIME-Version: 1.0
> Content-Type: text/plain; charset=UTF-8
> Content-Transfer-Encoding: 8bit
> 
> * nt/gnulib-cfg.mk (OMIT_GNULIB_MODULE_free-posix)
> (OMIT_GNULIB_MODULE_malloc-posix)
> (OMIT_GNULIB_MODULE_realloc-gnu)
> (OMIT_GNULIB_MODULE_realloc-posix):
> New macros, since we don’t want these modules on MS-Windows.
> * src/w32heap.c (heap_alloc, heap_realloc): New functions.
> (malloc_after_dump, realloc_after_dump, realloc_before_dump):
> Use them.

Thanks, this LGTM, but I have one minor request:

> +static void *
> +heap_alloc (size_t size)
> +{
> +  void *p = size <= PTRDIFF_MAX ? HeapAlloc (heap, 0, size | !size) : NULL;

Please add a comment here to explain the rationale for the
"size | !size" trick.

> +static void *
> +heap_realloc (void *ptr, size_t size)
> +{
> +  void *p = (size <= PTRDIFF_MAX
> +	     ? HeapReAlloc (heap, 0, ptr, size | !size)

Likewise here.

Btw, HeapAlloc does return a non-NULL pointer if SIZE is zero, so I'm
not sure the protection is needed.  But it cannot hurt.