From e584a005ac06fb3af48cff9f4d9ed352de60fea3 Mon Sep 17 00:00:00 2001 From: Sacha Date: Mon, 22 Apr 2013 14:22:18 +1000 Subject: [PATCH] Define vasprintf is native, for Blackberry --- base/stringutil.h | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/base/stringutil.h b/base/stringutil.h index 026c2d0ff3..fe607fa9aa 100644 --- a/base/stringutil.h +++ b/base/stringutil.h @@ -5,6 +5,7 @@ #include #include #include +#include #include #include "base/basictypes.h" @@ -13,6 +14,42 @@ #pragma warning (disable:4996) #endif +#ifdef BLACKBERRY +// QNX Does not have an implementation of vasprintf +static inline int vasprintf(char **rResult, const char *aFormat, va_list aAp) +{ + int rVal; + char *result; + va_list ap; + + result = (char *) malloc(16); + if (result == NULL) return -1; + + va_copy(ap, aAp); + rVal = vsnprintf(result, 16, aFormat, ap); + va_end(ap); + + if (rVal == -1) + { + free(result); + return rVal; + } + else if (rVal >= 16) + { + free(result); + result = (char *) malloc(rVal + 1); + if (result == NULL) return -1; + + va_copy(ap, aAp); + rVal = vsnprintf(result, rVal + 1, aFormat, aAp); + va_end(ap); + } + + *rResult = result; + return rVal; +} +#endif + // Dumb wrapper around itoa, providing a buffer. Declare this on the stack. class ITOA { public: