iliaa Sun May 16 11:34:56 2004 EDT
Modified files: (Branch: PHP_4_3)
/php-src/ext/sockets sockets.c
Log:
MFH: 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.125.2.20&r2=1.125.2.21&ty=u
Index: php-src/ext/sockets/sockets.c
diff -u php-src/ext/sockets/sockets.c:1.125.2.20
php-src/ext/sockets/sockets.c:1.125.2.21
--- php-src/ext/sockets/sockets.c:1.125.2.20 Wed Feb 25 17:12:03 2004
+++ php-src/ext/sockets/sockets.c Sun May 16 11:34:56 2004
@@ -19,7 +19,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: sockets.c,v 1.125.2.20 2004/02/25 22:12:03 iliaa Exp $ */
+/* $Id: sockets.c,v 1.125.2.21 2004/05/16 15:34:56 iliaa Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -350,7 +350,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
@@ -364,7 +364,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);
@@ -483,18 +483,18 @@
/* {{{ PHP_RINIT_FUNCTION */
PHP_RINIT_FUNCTION(sockets)
{
- if ((SOCKETS_G(strerror_buf) = emalloc(16384)))
- return SUCCESS;
-
- return FAILURE;
+ return SUCCESS;
}
/* }}} */
/* {{{ 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