iliaa Sun May 16 11:34:53 2004 EDT
Modified files:
/php-src/ext/sockets sockets.c
Log:
Do not allocate error buffer at the start of every request.
http://cvs.php.net/diff.php/php-src/ext/sockets/sockets.c?r1=1.161&r2=1.162&ty=u
Index: php-src/ext/sockets/sockets.c
diff -u php-src/ext/sockets/sockets.c:1.161 php-src/ext/sockets/sockets.c:1.162
--- php-src/ext/sockets/sockets.c:1.161 Sun Mar 14 12:53:28 2004
+++ php-src/ext/sockets/sockets.c Sun May 16 11:34:53 2004
@@ -19,7 +19,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: sockets.c,v 1.161 2004/03/14 17:53:28 jan Exp $ */
+/* $Id: sockets.c,v 1.162 2004/05/16 15:34:53 iliaa Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -322,7 +322,7 @@
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 @@
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_RINIT_FUNCTION */
PHP_RINIT_FUNCTION(sockets)
{
- SOCKETS_G(strerror_buf) = emalloc(16384);
-
return SUCCESS;
}
/* }}} */
@@ -512,8 +510,11 @@
/* {{{ 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;
}
/* }}} */
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php