[PATCH 1/3] Turn deprecated allocation functions into deprecated macros

Keith Packard keithp at keithp.com
Tue May 18 11:11:54 PDT 2010


On Wed, 19 May 2010 00:41:01 +0700, Mikhail Gusarov <dottedmag at dottedmag.net> wrote:
> This changes ABI of server as Xalloc/Xfree/Xrealloc/Xstrdup are
> no longer exported. OTOH, API is not changed as deprecated
> functions are replaced with macros which call C functions instead.

I think you can use static inline functions for these, which might make
deprecating them cleaner.

> +/*
> + * Use strdup(3) instead. The only difference from the library function that it
> + * is safe to pass NULL, and NULL will be returned.
> + */
> +#define xstrdup(s) (deprecated_Xxalloc, (s) ? strdup(s) : NULL)
> +#define Xstrdup(s) (deprecated_Xxalloc, (s) ? strdup(s) : NULL)

Also, for this function, a static inline will avoid evaluating 's'
twice.

-- 
keith.packard at intel.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.x.org/archives/xorg-devel/attachments/20100518/47f07418/attachment.pgp>


More information about the xorg-devel mailing list