[PATCH 2/7] Add asprintf() implementation for platforms without it

Alan Coopersmith alan.coopersmith at oracle.com
Fri Dec 3 23:43:19 PST 2010


Jeremy Huddleston wrote:
> On Dec 3, 2010, at 21:09, Alan Coopersmith wrote:
> ...
>> +extern _X_EXPORT int Xasprintf (char **ret,
>> +				const char * _X_RESTRICT_KYWD fmt,
>> +				...) _X_ATTRIBUTE_PRINTF(2,3);
>> +extern _X_EXPORT int Xvasprintf (char **ret,
>> +				 const char * _X_RESTRICT_KYWD fmt,
>> +				 va_list va);
>> +extern _X_EXPORT int XNFasprintf (char **ret,
>> +				  const char * _X_RESTRICT_KYWD fmt,
>> +				  ...) _X_ATTRIBUTE_PRINTF(2,3);
>> +extern _X_EXPORT int XNFvasprintf (char **ret,
>> +				   const char * _X_RESTRICT_KYWD fmt,
>> +				   va_list va);
>> +
>>
> 
> ...
> 
>> -extern _X_EXPORT char *Xprintf(const char *fmt, ...) _X_ATTRIBUTE_PRINTF(1,2);
>> -extern _X_EXPORT char *Xvprintf(const char *fmt, va_list va);
>> -extern _X_EXPORT char *XNFprintf(const char *fmt, ...) _X_ATTRIBUTE_PRINTF(1,2);
>> -extern _X_EXPORT char *XNFvprintf(const char *fmt, va_list va);
>> +/* Include new X*asprintf API */
>> +#include "Xprintf.h"
>> +
>> +/* Older api deprecated in favor of the asprintf versions */
>> +extern _X_EXPORT char *Xprintf(const char *fmt, ...) _X_ATTRIBUTE_PRINTF(1,2) _X_DEPRECATED;
>> +extern _X_EXPORT char *Xvprintf(const char *fmt, va_list va) _X_DEPRECATED;
>> +extern _X_EXPORT char *XNFprintf(const char *fmt, ...) _X_ATTRIBUTE_PRINTF(1,2) _X_DEPRECATED;
>> +extern _X_EXPORT char *XNFvprintf(const char *fmt, va_list va) _X_DEPRECATED;
>>
> 
> The "v" versions are missing _X_ATTRIBUTE_PRINTF.  They should be _X_ATTRIBUTE_PRINTF(2,0) for the "as" ones and _X_ATTRIBUTE_PRINTF(1,0) for
> the vanilla ones.

Oh, I didn't realize you could do that with varargs versions
(and apparently neither did whoever added them to the old API).

Thanks - will add those.


-- 
	-Alan Coopersmith-        alan.coopersmith at oracle.com
	 Oracle Solaris Platform Engineering: X Window System



More information about the xorg-devel mailing list