iliaa Sat May 19 18:32:35 2007 UTC
Modified files: (Branch: PHP_5_2)
/php-src/ext/spl php_spl.c
Log:
Eliminate memory allocation in RINIT for spl
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/php_spl.c?r1=1.52.2.28.2.15&r2=1.52.2.28.2.16&diff_format=u
Index: php-src/ext/spl/php_spl.c
diff -u php-src/ext/spl/php_spl.c:1.52.2.28.2.15
php-src/ext/spl/php_spl.c:1.52.2.28.2.16
--- php-src/ext/spl/php_spl.c:1.52.2.28.2.15 Fri Apr 6 16:00:08 2007
+++ php-src/ext/spl/php_spl.c Sat May 19 18:32:35 2007
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_spl.c,v 1.52.2.28.2.15 2007/04/06 16:00:08 helly Exp $ */
+/* $Id: php_spl.c,v 1.52.2.28.2.16 2007/05/19 18:32:35 iliaa Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -45,6 +45,8 @@
ZEND_DECLARE_MODULE_GLOBALS(spl)
+#define SPL_DEFAULT_FILE_EXTRNSIONS ".inc,.php"
+
/* {{{ spl_functions_none
*/
zend_function_entry spl_functions_none[] = {
@@ -271,7 +273,11 @@
RETURN_FALSE;
}
- copy = pos1 = estrndup(file_exts, file_exts_len);
+ if (file_exts == NULL) { /* autoload_extensions is not intialzed, set
to defaults */
+ copy = pos1 = estrndup(SPL_DEFAULT_FILE_EXTRNSIONS,
sizeof(SPL_DEFAULT_FILE_EXTRNSIONS)-1);
+ } else {
+ copy = pos1 = estrndup(file_exts, file_exts_len);
+ }
lc_name = zend_str_tolower_dup(class_name, class_name_len);
while(pos1 && *pos1 && !EG(exception)) {
EG(return_value_ptr_ptr) = original_return_value;
@@ -328,7 +334,11 @@
SPL_G(autoload_extensions_len) = file_exts_len;
}
- RETURN_STRINGL(SPL_G(autoload_extensions),
SPL_G(autoload_extensions_len), 1);
+ if (SPL_G(autoload_extensions) == NULL) {
+ RETURN_STRINGL(SPL_DEFAULT_FILE_EXTRNSIONS,
sizeof(SPL_DEFAULT_FILE_EXTRNSIONS) - 1, 1);
+ } else {
+ RETURN_STRINGL(SPL_G(autoload_extensions),
SPL_G(autoload_extensions_len), 1);
+ }
} /* }}} */
typedef struct {
@@ -717,8 +727,8 @@
PHP_RINIT_FUNCTION(spl) /* {{{ */
{
- SPL_G(autoload_extensions) = estrndup(".inc,.php",
sizeof(".inc,.php")-1);
- SPL_G(autoload_extensions_len) = sizeof(".inc,.php")-1;
+ SPL_G(autoload_extensions) = NULL;
+ SPL_G(autoload_extensions_len) = 0;
SPL_G(autoload_functions) = NULL;
return SUCCESS;
} /* }}} */
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php