After a recent conversation on Mastodon about how checking if a malloc()
implementation returns NULL for malloc(0) at build time can give different
answers than you may get at runtime if an application or LD_PRELOAD has
interposed a different malloc implementation, I wrote a patch to our
autoconf macros to stop checking and instead always assume we need to
handle that case:

https://gitlab.freedesktop.org/xorg/util/macros/-/merge_requests/9

It's been sitting in gitlab for 2 weeks without comment - I figured I'd
give a larger audience a chance to chime in before I go ahead and merge
it - but if I don't hear anything soon, I'll do just that.

(Mainly this makes code like libX11 define malloc wrapper macros such as:
# define Xmalloc(size) malloc((size_t)((size) == 0 ? 1 : (size)))
which the compiler can hopefully optimize down to a simple malloc(size)
for most calls when the value is known to be non-zero at compile time.)

--
        -Alan Coopersmith-                 [email protected]
         Oracle Solaris Engineering - https://blogs.oracle.com/solaris

Reply via email to