diff options
author | Scott MacVicar <scottmac@php.net> | 2008-11-27 19:45:27 +0000 |
---|---|---|
committer | Scott MacVicar <scottmac@php.net> | 2008-11-27 19:45:27 +0000 |
commit | ceabdbb4832d04ad625c898031e7dd730a10df04 (patch) | |
tree | 0b6fe9c7e51dfdff3b23a8d5a954cf6ffbb08b33 /main | |
parent | 7d4fd3fd380a7fe9b497684775a38190786b93ba (diff) | |
download | php-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')
-rw-r--r-- | main/snprintf.c | 16 | ||||
-rw-r--r-- | main/snprintf.h | 10 |
2 files changed, 21 insertions, 5 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 diff --git a/main/snprintf.h b/main/snprintf.h index c55d5cb35a..0b7470874e 100644 --- a/main/snprintf.h +++ b/main/snprintf.h @@ -83,6 +83,7 @@ PHPAPI int ap_php_vslprintf(char *buf, size_t len, const char *format, va_list a 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, @@ -110,10 +111,13 @@ END_EXTERN_C() #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 |