Add asprintf() implementation for platforms without it
Provides a portable implementation of this common allocating sprintf() API found in many, but not yet all, of the platforms we support. If the platform provides vasprintf() we simply wrap it, otherwise we implement it - either way callers can use it regardless of platform. Since not all platforms guarantee to NULL out the return pointer on failure, we don't either, and require callers to check the return value for -1. The old Xprintf() API is deprecated, but left for compatibility for now. The new API is added in a new header so that it can be used in parts of the server such as hw/xfree86/parser that don't include all the server headers. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Mikhail Gusarov <dottedmag@dottedmag.net>
This commit is contained in:
12
include/os.h
12
include/os.h
@@ -263,10 +263,14 @@ extern _X_EXPORT char *Xstrdup(const char *s);
|
||||
*/
|
||||
extern _X_EXPORT char *XNFstrdup(const char *s);
|
||||
|
||||
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_ATTRIBUTE_PRINTF(1,0) _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_ATTRIBUTE_PRINTF(1,0) _X_DEPRECATED;
|
||||
|
||||
typedef void (*OsSigHandlerPtr)(int /* sig */);
|
||||
typedef int (*OsSigWrapperPtr)(int /* sig */);
|
||||
|
||||
Reference in New Issue
Block a user