mirror of
https://github.com/php/php-src.git
synced 2024-11-24 18:34:21 +08:00
Do not allocate error buffer at the start of every request.
This commit is contained in:
parent
ed5ce047db
commit
bb88a86240
@ -322,7 +322,7 @@ static char *php_strerror(int error TSRMLS_DC)
|
||||
buf = hstrerror(error);
|
||||
#else
|
||||
{
|
||||
sprintf(SOCKETS_G(strerror_buf), "Host lookup error %d", error);
|
||||
spprintf(&(SOCKETS_G(strerror_buf), "Host lookup error %d", error);
|
||||
buf = SOCKETS_G(strerror_buf);
|
||||
}
|
||||
#endif
|
||||
@ -336,7 +336,7 @@ static char *php_strerror(int error TSRMLS_DC)
|
||||
|
||||
if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
NULL, error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &tmp, 0, NULL)) {
|
||||
strlcpy(SOCKETS_G(strerror_buf), (char *) tmp, 10000);
|
||||
SOCKETS_G(strerror_buf) = estrndup(tmp);
|
||||
LocalFree(tmp);
|
||||
|
||||
buf = SOCKETS_G(strerror_buf);
|
||||
@ -503,8 +503,6 @@ PHP_MINFO_FUNCTION(sockets)
|
||||
/* {{{ PHP_RINIT_FUNCTION */
|
||||
PHP_RINIT_FUNCTION(sockets)
|
||||
{
|
||||
SOCKETS_G(strerror_buf) = emalloc(16384);
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
/* }}} */
|
||||
@ -512,8 +510,11 @@ PHP_RINIT_FUNCTION(sockets)
|
||||
/* {{{ PHP_RSHUTDOWN_FUNCTION */
|
||||
PHP_RSHUTDOWN_FUNCTION(sockets)
|
||||
{
|
||||
efree(SOCKETS_G(strerror_buf));
|
||||
|
||||
if (SOCKETS_G(strerror_buf)) {
|
||||
efree(SOCKETS_G(strerror_buf));
|
||||
SOCKETS_G(strerror_buf) = NULL;
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
/* }}} */
|
||||
|
Loading…
Reference in New Issue
Block a user