[PHP-CVS] cvs: php-src(PHP_5_3) /ext/spl php_spl.c php_spl.h
colder Mon Jan 26 11:38:03 2009 UTC Modified files: (Branch: PHP_5_3) /php-src/ext/splphp_spl.c php_spl.h Log: MFH: Improve spl_object_hash() http://cvs.php.net/viewvc.cgi/php-src/ext/spl/php_spl.c?r1=1.52.2.28.2.17.2.34r2=1.52.2.28.2.17.2.35diff_format=u Index: php-src/ext/spl/php_spl.c diff -u php-src/ext/spl/php_spl.c:1.52.2.28.2.17.2.34 php-src/ext/spl/php_spl.c:1.52.2.28.2.17.2.35 --- php-src/ext/spl/php_spl.c:1.52.2.28.2.17.2.34 Wed Dec 31 11:15:43 2008 +++ php-src/ext/spl/php_spl.c Mon Jan 26 11:38:03 2009 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_spl.c,v 1.52.2.28.2.17.2.34 2008/12/31 11:15:43 sebastian Exp $ */ +/* $Id: php_spl.c,v 1.52.2.28.2.17.2.35 2009/01/26 11:38:03 colder Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -39,7 +39,9 @@ #include spl_heap.h #include zend_exceptions.h #include zend_interfaces.h -#include ext/standard/md5.h +#include ext/standard/php_rand.h +#include ext/standard/php_lcg.h +#include main/snprintf.h #ifdef COMPILE_DL_SPL ZEND_GET_MODULE(spl) @@ -669,34 +671,41 @@ PHP_FUNCTION(spl_object_hash) { zval *obj; - char* md5str; + char* hash; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, o, obj) == FAILURE) { return; } - md5str = emalloc(33); - php_spl_object_hash(obj, md5str TSRMLS_CC); + hash = emalloc(33); + php_spl_object_hash(obj, hash TSRMLS_CC); - RETVAL_STRING(md5str, 0); + RETVAL_STRING(hash, 0); } /* }}} */ -PHPAPI void php_spl_object_hash(zval *obj, char *md5str TSRMLS_DC) /* {{{*/ +PHPAPI void php_spl_object_hash(zval *obj, char *result TSRMLS_DC) /* {{{*/ { - int len; - char *hash; - PHP_MD5_CTX context; - unsigned char digest[16]; - - len = spprintf(hash, 0, %p:%d, Z_OBJ_HT_P(obj), Z_OBJ_HANDLE_P(obj)); - - md5str[0] = '\0'; - PHP_MD5Init(context); - PHP_MD5Update(context, (unsigned char*)hash, len); - PHP_MD5Final(digest, context); - make_digest(md5str, digest); - efree(hash); + intptr_t hash_handle, hash_handlers; + char *hex; + + if (!SPL_G(hash_mask_init)) { + if (!BG(mt_rand_is_seeded)) { + php_mt_srand(GENERATE_SEED() TSRMLS_CC); + } + + SPL_G(hash_mask_handle) = (intptr_t)(php_mt_rand(TSRMLS_C) 1); + SPL_G(hash_mask_handlers) = (intptr_t)(php_mt_rand(TSRMLS_C) 1); + SPL_G(hash_mask_init) = 1; + } + + hash_handle = SPL_G(hash_mask_handle)^(intptr_t)Z_OBJ_HANDLE_P(obj); + hash_handlers = SPL_G(hash_mask_handlers)^(intptr_t)Z_OBJ_HT_P(obj); + + spprintf(hex, 32, %016x%016x, hash_handle, hash_handlers); + + strlcpy(result, hex, 33); + efree(hex); } /* }}} */ @@ -844,6 +853,7 @@ SPL_G(autoload_extensions) = NULL; SPL_G(autoload_extensions_len) = 0; SPL_G(autoload_functions) = NULL; + SPL_G(hash_mask_init) = 0; return SUCCESS; } /* }}} */ @@ -859,6 +869,9 @@ FREE_HASHTABLE(SPL_G(autoload_functions)); SPL_G(autoload_functions) = NULL; } + if (SPL_G(hash_mask_init)) { + SPL_G(hash_mask_init) = 0; + } return SUCCESS; } /* }}} */ http://cvs.php.net/viewvc.cgi/php-src/ext/spl/php_spl.h?r1=1.17.2.1.2.3.2.6r2=1.17.2.1.2.3.2.7diff_format=u Index: php-src/ext/spl/php_spl.h diff -u php-src/ext/spl/php_spl.h:1.17.2.1.2.3.2.6 php-src/ext/spl/php_spl.h:1.17.2.1.2.3.2.7 --- php-src/ext/spl/php_spl.h:1.17.2.1.2.3.2.6 Wed Dec 31 11:15:43 2008 +++ php-src/ext/spl/php_spl.h Mon Jan 26 11:38:03 2009 @@ -62,6 +62,9 @@ HashTable * autoload_functions; int autoload_running; int autoload_extensions_len; + intptr_t hash_mask_handle; + intptr_t hash_mask_handlers; + int hash_mask_init; ZEND_END_MODULE_GLOBALS(spl) #ifdef ZTS -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_3) /ext/spl php_spl.c php_spl.h /ext/tidy php_tidy.h tidy.c
helly Sun Jan 27 15:04:41 2008 UTC Modified files: (Branch: PHP_5_3) /php-src/ext/splphp_spl.c php_spl.h /php-src/ext/tidy php_tidy.h tidy.c Log: - MFH revert over constfying http://cvs.php.net/viewvc.cgi/php-src/ext/spl/php_spl.c?r1=1.52.2.28.2.17.2.8r2=1.52.2.28.2.17.2.9diff_format=u Index: php-src/ext/spl/php_spl.c diff -u php-src/ext/spl/php_spl.c:1.52.2.28.2.17.2.8 php-src/ext/spl/php_spl.c:1.52.2.28.2.17.2.9 --- php-src/ext/spl/php_spl.c:1.52.2.28.2.17.2.8Fri Jan 25 20:29:48 2008 +++ php-src/ext/spl/php_spl.c Sun Jan 27 15:04:41 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_spl.c,v 1.52.2.28.2.17.2.8 2008/01/25 20:29:48 nlopess Exp $ */ +/* $Id: php_spl.c,v 1.52.2.28.2.17.2.9 2008/01/27 15:04:41 helly Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -764,7 +764,7 @@ /* {{{ spl_module_entry */ -const zend_module_entry spl_module_entry = { +zend_module_entry spl_module_entry = { #ifdef HAVE_SIMPLEXML STANDARD_MODULE_HEADER_EX, NULL, spl_deps, http://cvs.php.net/viewvc.cgi/php-src/ext/spl/php_spl.h?r1=1.17.2.1.2.3.2.3r2=1.17.2.1.2.3.2.4diff_format=u Index: php-src/ext/spl/php_spl.h diff -u php-src/ext/spl/php_spl.h:1.17.2.1.2.3.2.3 php-src/ext/spl/php_spl.h:1.17.2.1.2.3.2.4 --- php-src/ext/spl/php_spl.h:1.17.2.1.2.3.2.3 Fri Jan 25 20:29:48 2008 +++ php-src/ext/spl/php_spl.h Sun Jan 27 15:04:41 2008 @@ -28,7 +28,7 @@ #define SPL_DEBUG(x) #endif -extern const zend_module_entry spl_module_entry; +extern zend_module_entry spl_module_entry; #define phpext_spl_ptr spl_module_entry #ifdef PHP_WIN32 http://cvs.php.net/viewvc.cgi/php-src/ext/tidy/php_tidy.h?r1=1.26.2.1.2.5.2.2r2=1.26.2.1.2.5.2.3diff_format=u Index: php-src/ext/tidy/php_tidy.h diff -u php-src/ext/tidy/php_tidy.h:1.26.2.1.2.5.2.2 php-src/ext/tidy/php_tidy.h:1.26.2.1.2.5.2.3 --- php-src/ext/tidy/php_tidy.h:1.26.2.1.2.5.2.2Fri Jan 25 20:29:48 2008 +++ php-src/ext/tidy/php_tidy.h Sun Jan 27 15:04:41 2008 @@ -16,12 +16,12 @@ +--+ */ -/* $Id: php_tidy.h,v 1.26.2.1.2.5.2.2 2008/01/25 20:29:48 nlopess Exp $ */ +/* $Id: php_tidy.h,v 1.26.2.1.2.5.2.3 2008/01/27 15:04:41 helly Exp $ */ #ifndef PHP_TIDY_H #define PHP_TIDY_H -extern const zend_module_entry tidy_module_entry; +extern zend_module_entry tidy_module_entry; #define phpext_tidy_ptr tidy_module_entry #define TIDY_METHOD_MAP(name, func_name, arg_types) \ http://cvs.php.net/viewvc.cgi/php-src/ext/tidy/tidy.c?r1=1.66.2.8.2.24.2.4r2=1.66.2.8.2.24.2.5diff_format=u Index: php-src/ext/tidy/tidy.c diff -u php-src/ext/tidy/tidy.c:1.66.2.8.2.24.2.4 php-src/ext/tidy/tidy.c:1.66.2.8.2.24.2.5 --- php-src/ext/tidy/tidy.c:1.66.2.8.2.24.2.4 Fri Jan 25 20:29:48 2008 +++ php-src/ext/tidy/tidy.c Sun Jan 27 15:04:41 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: tidy.c,v 1.66.2.8.2.24.2.4 2008/01/25 20:29:48 nlopess Exp $ */ +/* $Id: tidy.c,v 1.66.2.8.2.24.2.5 2008/01/27 15:04:41 helly Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -351,7 +351,7 @@ static zend_object_handlers tidy_object_handlers_doc; static zend_object_handlers tidy_object_handlers_node; -const zend_module_entry tidy_module_entry = { +zend_module_entry tidy_module_entry = { STANDARD_MODULE_HEADER, tidy, tidy_functions, @@ -998,7 +998,7 @@ php_info_print_table_start(); php_info_print_table_header(2, Tidy support, enabled); php_info_print_table_row(2, libTidy Release, (char *)tidyReleaseDate()); - php_info_print_table_row(2, Extension Version, PHP_TIDY_MODULE_VERSION ($Id: tidy.c,v 1.66.2.8.2.24.2.4 2008/01/25 20:29:48 nlopess Exp $)); + php_info_print_table_row(2, Extension Version, PHP_TIDY_MODULE_VERSION ($Id: tidy.c,v 1.66.2.8.2.24.2.5 2008/01/27 15:04:41 helly Exp $)); php_info_print_table_end(); DISPLAY_INI_ENTRIES(); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src(PHP_5_3) /ext/spl php_spl.c php_spl.h /ext/tidy php_tidy.h tidy.c
Confirmed, gave me a headache today ... - Markus Antony Dovgal wrote: On 25.01.2008 23:29, Nuno Lopes wrote: -zend_module_entry spl_module_entry = { +const zend_module_entry spl_module_entry = { -zend_module_entry tidy_module_entry = { +const zend_module_entry tidy_module_entry = { This makes PHP to crash right after the start. Please revert. -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src(PHP_5_3) /ext/spl php_spl.c php_spl.h /ext/tidy php_tidy.h tidy.c
On 25.01.2008 23:29, Nuno Lopes wrote: -zend_module_entry spl_module_entry = { +const zend_module_entry spl_module_entry = { -zend_module_entry tidy_module_entry = { +const zend_module_entry tidy_module_entry = { This makes PHP to crash right after the start. Please revert. Ah damn.. Sorry for the breakage and thanks for letting me know about this. (I though I had tested everything...) Tomorrow I'll fix it (today I'm just too tired). Thanks, Nuno -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src(PHP_5_3) /ext/spl php_spl.c php_spl.h /ext/tidy php_tidy.h tidy.c
On 25.01.2008 23:29, Nuno Lopes wrote: -zend_module_entry spl_module_entry = { +const zend_module_entry spl_module_entry = { -zend_module_entry tidy_module_entry = { +const zend_module_entry tidy_module_entry = { This makes PHP to crash right after the start. Please revert. -- Wbr, Antony Dovgal -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_3) /ext/spl php_spl.c php_spl.h /ext/tidy php_tidy.h tidy.c
nlopess Fri Jan 25 20:29:48 2008 UTC Modified files: (Branch: PHP_5_3) /php-src/ext/splphp_spl.c php_spl.h /php-src/ext/tidy php_tidy.h tidy.c Log: more const kewywording remove spl_functions_none var (wast used anywhere http://cvs.php.net/viewvc.cgi/php-src/ext/spl/php_spl.c?r1=1.52.2.28.2.17.2.7r2=1.52.2.28.2.17.2.8diff_format=u Index: php-src/ext/spl/php_spl.c diff -u php-src/ext/spl/php_spl.c:1.52.2.28.2.17.2.7 php-src/ext/spl/php_spl.c:1.52.2.28.2.17.2.8 --- php-src/ext/spl/php_spl.c:1.52.2.28.2.17.2.7Tue Jan 15 09:38:15 2008 +++ php-src/ext/spl/php_spl.c Fri Jan 25 20:29:48 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_spl.c,v 1.52.2.28.2.17.2.7 2008/01/15 09:38:15 colder Exp $ */ +/* $Id: php_spl.c,v 1.52.2.28.2.17.2.8 2008/01/25 20:29:48 nlopess Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -48,13 +48,6 @@ #define SPL_DEFAULT_FILE_EXTENSIONS .inc,.php -/* {{{ spl_functions_none - */ -const zend_function_entry spl_functions_none[] = { - {NULL, NULL, NULL} -}; -/* }}} */ - /* {{{ PHP_GINIT_FUNCTION */ static PHP_GINIT_FUNCTION(spl) @@ -771,7 +764,7 @@ /* {{{ spl_module_entry */ -zend_module_entry spl_module_entry = { +const zend_module_entry spl_module_entry = { #ifdef HAVE_SIMPLEXML STANDARD_MODULE_HEADER_EX, NULL, spl_deps, http://cvs.php.net/viewvc.cgi/php-src/ext/spl/php_spl.h?r1=1.17.2.1.2.3.2.2r2=1.17.2.1.2.3.2.3diff_format=u Index: php-src/ext/spl/php_spl.h diff -u php-src/ext/spl/php_spl.h:1.17.2.1.2.3.2.2 php-src/ext/spl/php_spl.h:1.17.2.1.2.3.2.3 --- php-src/ext/spl/php_spl.h:1.17.2.1.2.3.2.2 Mon Dec 31 07:17:14 2007 +++ php-src/ext/spl/php_spl.h Fri Jan 25 20:29:48 2008 @@ -28,7 +28,7 @@ #define SPL_DEBUG(x) #endif -extern zend_module_entry spl_module_entry; +extern const zend_module_entry spl_module_entry; #define phpext_spl_ptr spl_module_entry #ifdef PHP_WIN32 http://cvs.php.net/viewvc.cgi/php-src/ext/tidy/php_tidy.h?r1=1.26.2.1.2.5.2.1r2=1.26.2.1.2.5.2.2diff_format=u Index: php-src/ext/tidy/php_tidy.h diff -u php-src/ext/tidy/php_tidy.h:1.26.2.1.2.5.2.1 php-src/ext/tidy/php_tidy.h:1.26.2.1.2.5.2.2 --- php-src/ext/tidy/php_tidy.h:1.26.2.1.2.5.2.1Mon Dec 31 07:17:16 2007 +++ php-src/ext/tidy/php_tidy.h Fri Jan 25 20:29:48 2008 @@ -16,12 +16,12 @@ +--+ */ -/* $Id: php_tidy.h,v 1.26.2.1.2.5.2.1 2007/12/31 07:17:16 sebastian Exp $ */ +/* $Id: php_tidy.h,v 1.26.2.1.2.5.2.2 2008/01/25 20:29:48 nlopess Exp $ */ #ifndef PHP_TIDY_H #define PHP_TIDY_H -extern zend_module_entry tidy_module_entry; +extern const zend_module_entry tidy_module_entry; #define phpext_tidy_ptr tidy_module_entry #define TIDY_METHOD_MAP(name, func_name, arg_types) \ http://cvs.php.net/viewvc.cgi/php-src/ext/tidy/tidy.c?r1=1.66.2.8.2.24.2.3r2=1.66.2.8.2.24.2.4diff_format=u Index: php-src/ext/tidy/tidy.c diff -u php-src/ext/tidy/tidy.c:1.66.2.8.2.24.2.3 php-src/ext/tidy/tidy.c:1.66.2.8.2.24.2.4 --- php-src/ext/tidy/tidy.c:1.66.2.8.2.24.2.3 Mon Dec 31 07:17:16 2007 +++ php-src/ext/tidy/tidy.c Fri Jan 25 20:29:48 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: tidy.c,v 1.66.2.8.2.24.2.3 2007/12/31 07:17:16 sebastian Exp $ */ +/* $Id: tidy.c,v 1.66.2.8.2.24.2.4 2008/01/25 20:29:48 nlopess Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -351,7 +351,7 @@ static zend_object_handlers tidy_object_handlers_doc; static zend_object_handlers tidy_object_handlers_node; -zend_module_entry tidy_module_entry = { +const zend_module_entry tidy_module_entry = { STANDARD_MODULE_HEADER, tidy, tidy_functions, @@ -998,7 +998,7 @@ php_info_print_table_start(); php_info_print_table_header(2, Tidy support, enabled); php_info_print_table_row(2, libTidy Release, (char *)tidyReleaseDate()); - php_info_print_table_row(2, Extension Version, PHP_TIDY_MODULE_VERSION ($Id: tidy.c,v 1.66.2.8.2.24.2.3 2007/12/31 07:17:16 sebastian Exp $)); + php_info_print_table_row(2, Extension Version, PHP_TIDY_MODULE_VERSION ($Id: tidy.c,v 1.66.2.8.2.24.2.4 2008/01/25 20:29:48 nlopess Exp $)); php_info_print_table_end(); DISPLAY_INI_ENTRIES(); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php