mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
MFH Add asprintf, use regular system malloc and free and add checks in configure.in for the functions
This commit is contained in:
parent
7d4fd3fd38
commit
ceabdbb483
4 changed files with 24 additions and 6 deletions
|
@ -637,6 +637,8 @@ usleep \
|
||||||
nanosleep \
|
nanosleep \
|
||||||
utime \
|
utime \
|
||||||
vsnprintf \
|
vsnprintf \
|
||||||
|
vasprintf \
|
||||||
|
asprintf \
|
||||||
)
|
)
|
||||||
|
|
||||||
dnl Check for getaddrinfo, should be a better way, but...
|
dnl Check for getaddrinfo, should be a better way, but...
|
||||||
|
|
|
@ -62,7 +62,7 @@ file_magwarn(struct magic_set *ms, const char *f, ...)
|
||||||
|
|
||||||
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Warning: %s", expanded_format);
|
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Warning: %s", expanded_format);
|
||||||
|
|
||||||
efree(expanded_format);
|
free(expanded_format);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected const char *
|
protected const char *
|
||||||
|
|
|
@ -1280,9 +1280,9 @@ PHPAPI int ap_php_vasprintf(char **buf, const char *format, va_list ap) /* {{{ *
|
||||||
*buf = NULL;
|
*buf = NULL;
|
||||||
|
|
||||||
if (cc >= 0) {
|
if (cc >= 0) {
|
||||||
if ((*buf = emalloc(++cc)) != NULL) {
|
if ((*buf = malloc(++cc)) != NULL) {
|
||||||
if ((cc = ap_php_vsnprintf(*buf, cc, format, ap)) < 0) {
|
if ((cc = ap_php_vsnprintf(*buf, cc, format, ap)) < 0) {
|
||||||
efree(*buf);
|
free(*buf);
|
||||||
*buf = NULL;
|
*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:
|
* Local variables:
|
||||||
* tab-width: 4
|
* tab-width: 4
|
||||||
|
|
|
@ -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_snprintf(char *, size_t, const char *, ...);
|
||||||
PHPAPI int ap_php_vsnprintf(char *, size_t, const char *, va_list ap);
|
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_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 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_gcvt(double value, int ndigit, char dec_point, char exponent, char *buf);
|
||||||
PHPAPI char * php_conv_fp(register char format, register double num,
|
PHPAPI char * php_conv_fp(register char format, register double num,
|
||||||
|
@ -110,10 +111,13 @@ END_EXTERN_C()
|
||||||
#endif
|
#endif
|
||||||
#define vsnprintf ap_php_vsnprintf
|
#define vsnprintf ap_php_vsnprintf
|
||||||
|
|
||||||
#ifdef vasprintf
|
#ifndef HAVE_VASPRINTF
|
||||||
#undef vasprintf
|
|
||||||
#endif
|
|
||||||
#define vasprintf ap_php_vasprintf
|
#define vasprintf ap_php_vasprintf
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_ASPRINTF
|
||||||
|
#define asprintf ap_php_asprintf
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef sprintf
|
#ifdef sprintf
|
||||||
#undef sprintf
|
#undef sprintf
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue