* - good performance for large string handling (large format, large
* argument or large paddings). Performance is similar to system's sprintf
* and in several cases significantly better (make sure you compile with
* optimizations turned on, tell the compiler the code is strict ANSI
* - good performance for large string handling (large format, large
* argument or large paddings). Performance is similar to system's sprintf
* and in several cases significantly better (make sure you compile with
* optimizations turned on, tell the compiler the code is strict ANSI
- * if necessary to give it more freedom for optimizations);
- * - return value semantics per ISO/IEC 9899:1999 ("ISO C99");
- * - written in standard ISO/ANSI C - requires an ANSI C compiler.
+ * if necessary to give it more freedom for optimizations)
+ * - return value semantics per ISO/IEC 9899:1999 ("ISO C99")
+ * - written in standard ISO/ANSI C - requires an ANSI C compiler
-int vasprintf(char **ptr, const char *fmt, va_list ap);
+int vasprintf(char** ptr, const char* fmt, va_list ap) XBT_ATTRIB_PRINTF(2, 0);
str_l = vsnprintf(NULL, (size_t) 0, fmt, ap2); /*get required size */
va_end(ap2);
}
str_l = vsnprintf(NULL, (size_t) 0, fmt, ap2); /*get required size */
va_end(ap2);
}
- xbt_assert(str_l >= 0); /* possible integer overflow if str_m > INT_MAX */
- *ptr = (char *) xbt_malloc(str_m = (size_t) str_l + 1);
+ assert(str_l >= 0); /* possible integer overflow if str_m > INT_MAX */
+ *ptr = (char*)malloc(str_m = (size_t)str_l + 1);
+ assert(*ptr != NULL);
int str_l2 = vsnprintf(*ptr, str_m, fmt, ap);
assert(str_l2 == str_l);
int str_l2 = vsnprintf(*ptr, str_m, fmt, ap);
assert(str_l2 == str_l);
if (vasprintf(&res, fmt, ap) < 0) {
/* Do not want to use xbt_die() here, as it uses the logging
if (vasprintf(&res, fmt, ap) < 0) {
/* Do not want to use xbt_die() here, as it uses the logging