*buf = NULL;
if (cc >= 0) {
- if ((*buf = emalloc(++cc)) != NULL) {
+ if ((*buf = malloc(++cc)) != NULL) {
if ((cc = ap_php_vsnprintf(*buf, cc, format, ap)) < 0) {
- efree(*buf);
+ free(*buf);
*buf = NULL;
}
}
}
/* }}} */
+PHPAPI int ap_php_asprintf(char **buf, const char *format, ...) /* {{{ */
+{
+ int cc;
+ va_list ap;
+
+ va_start(ap, format);
+ cc = vasprintf(buf, format, ap);
+ va_end(ap);
+ return cc;
+}
+/* }}} */
+
/*
* Local variables:
* tab-width: 4
PHPAPI int ap_php_snprintf(char *, size_t, const char *, ...);
PHPAPI int ap_php_vsnprintf(char *, size_t, const char *, va_list ap);
PHPAPI int ap_php_vasprintf(char **buf, const char *format, va_list ap);
+PHPAPI int ap_php_asprintf(char **buf, const char *format, ...);
PHPAPI int php_sprintf (char* s, const char* format, ...) PHP_ATTRIBUTE_FORMAT(printf, 2, 3);
PHPAPI char * php_gcvt(double value, int ndigit, char dec_point, char exponent, char *buf);
PHPAPI char * php_conv_fp(register char format, register double num,
#endif
#define vsnprintf ap_php_vsnprintf
-#ifdef vasprintf
-#undef vasprintf
-#endif
+#ifndef HAVE_VASPRINTF
#define vasprintf ap_php_vasprintf
+#endif
+
+#ifndef HAVE_ASPRINTF
+#define asprintf ap_php_asprintf
+#endif
#ifdef sprintf
#undef sprintf