summaryrefslogtreecommitdiff
path: root/main/snprintf.c
diff options
context:
space:
mode:
authorScott MacVicar <scottmac@php.net>2008-11-27 19:45:27 +0000
committerScott MacVicar <scottmac@php.net>2008-11-27 19:45:27 +0000
commitceabdbb4832d04ad625c898031e7dd730a10df04 (patch)
tree0b6fe9c7e51dfdff3b23a8d5a954cf6ffbb08b33 /main/snprintf.c
parent7d4fd3fd380a7fe9b497684775a38190786b93ba (diff)
downloadphp-git-ceabdbb4832d04ad625c898031e7dd730a10df04.tar.gz
MFH Add asprintf, use regular system malloc and free and add checks in configure.in for the functions
Diffstat (limited to 'main/snprintf.c')
-rw-r--r--main/snprintf.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/main/snprintf.c b/main/snprintf.c
index dbe7b10023..ac53a89303 100644
--- a/main/snprintf.c
+++ b/main/snprintf.c
@@ -1280,9 +1280,9 @@ PHPAPI int ap_php_vasprintf(char **buf, const char *format, va_list ap) /* {{{ *
*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;
}
}
@@ -1292,6 +1292,18 @@ PHPAPI int ap_php_vasprintf(char **buf, const char *format, va_list ap) /* {{{ *
}
/* }}} */
+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