summaryrefslogtreecommitdiff
path: root/ext/reflection/php_reflection.c
diff options
context:
space:
mode:
authorPierre Joye <pierre.php@gmail.com>2014-03-05 10:32:42 +0100
committerPierre Joye <pierre.php@gmail.com>2014-03-05 10:32:42 +0100
commite590aceb5ad05e59896fecfeb645f5a70919f417 (patch)
tree9812785c5ac4a8727ab1b2b2fa3b8012f7df7fd8 /ext/reflection/php_reflection.c
parent9b54901ffbfc1f5eacf3f75bdf01c76c78233264 (diff)
parentc2a9f73c99065cd8a7d3c08583498053076e1265 (diff)
downloadphp-git-e590aceb5ad05e59896fecfeb645f5a70919f417.tar.gz
Merge branch 'PHP-5.4' of git.php.net:php-src into PHP-5.4
# By Anatol Belski (22) and others # Via Derick Rethans (5) and others * 'PHP-5.4' of git.php.net:php-src: (176 commits) NEWS Fixed Bug #66820 out-of-bounds memory access in fileinfo Improves fix for memory leak, keep in sync with upstream. Updated news for #60602 proc_open(): separate environment values that aren't strings Updated NEWS for #66535 Fixed test case title [bug 66535] X-PHP-Originating-Script adds newline if no custom headers are given man page: long option name is --strip, not --stripped --global have be removed in 5.2 NEWS test for bug #66762 Fixed Bug #66762 Segfault in mysqli_stmt::bind_result() when link closed fix tests broken by 633f898f1520253d3530fe91fc82f68bca7c4627 add news entry add clear_env option to FPM config Reduce test noise on cross Oracle client <-> server version tests. This fix is already in PHP 5.6+ Reduce test noise in cross Oracle client <-> server version testing. This change is already in PHP 5.6+ fixed macro Make sure value is initialized ...
Diffstat (limited to 'ext/reflection/php_reflection.c')
-rw-r--r--ext/reflection/php_reflection.c68
1 files changed, 27 insertions, 41 deletions
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index c4a7c554f0..f6367cdb4e 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2013 The PHP Group |
+ | Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -1105,29 +1105,26 @@ static void _extension_string(string *str, zend_module_entry *module, char *inde
string_free(&str_constants);
}
- if (module->functions && module->functions->fname) {
+ {
+ HashPosition iterator;
zend_function *fptr;
- const zend_function_entry *func = module->functions;
-
- string_printf(str, "\n - Functions {\n");
-
- /* Is there a better way of doing this? */
- while (func->fname) {
- int fname_len = strlen(func->fname);
- char *lc_name = zend_str_tolower_dup(func->fname, fname_len);
-
- if (zend_hash_find(EG(function_table), lc_name, fname_len + 1, (void**) &fptr) == FAILURE) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Internal error: Cannot find extension function %s in global function table", func->fname);
- func++;
- efree(lc_name);
- continue;
+ int first = 1;
+
+ zend_hash_internal_pointer_reset_ex(CG(function_table), &iterator);
+ while (zend_hash_get_current_data_ex(CG(function_table), (void **) &fptr, &iterator) == SUCCESS) {
+ if (fptr->common.type==ZEND_INTERNAL_FUNCTION
+ && fptr->internal_function.module == module) {
+ if (first) {
+ string_printf(str, "\n - Functions {\n");
+ first = 0;
+ }
+ _function_string(str, fptr, NULL, " " TSRMLS_CC);
}
-
- _function_string(str, fptr, NULL, " " TSRMLS_CC);
- efree(lc_name);
- func++;
+ zend_hash_move_forward_ex(CG(function_table), &iterator);
+ }
+ if (!first) {
+ string_printf(str, "%s }\n", indent);
}
- string_printf(str, "%s }\n", indent);
}
{
@@ -5242,6 +5239,9 @@ ZEND_METHOD(reflection_extension, getFunctions)
{
reflection_object *intern;
zend_module_entry *module;
+ HashPosition iterator;
+ zval *function;
+ zend_function *fptr;
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -5249,29 +5249,15 @@ ZEND_METHOD(reflection_extension, getFunctions)
GET_REFLECTION_OBJECT_PTR(module);
array_init(return_value);
- if (module->functions) {
- zval *function;
- zend_function *fptr;
- const zend_function_entry *func = module->functions;
-
- /* Is there a better way of doing this? */
- while (func->fname) {
- int fname_len = strlen(func->fname);
- char *lc_name = zend_str_tolower_dup(func->fname, fname_len);
-
- if (zend_hash_find(EG(function_table), lc_name, fname_len + 1, (void**) &fptr) == FAILURE) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Internal error: Cannot find extension function %s in global function table", func->fname);
- func++;
- efree(lc_name);
- continue;
- }
-
+ zend_hash_internal_pointer_reset_ex(CG(function_table), &iterator);
+ while (zend_hash_get_current_data_ex(CG(function_table), (void **) &fptr, &iterator) == SUCCESS) {
+ if (fptr->common.type==ZEND_INTERNAL_FUNCTION
+ && fptr->internal_function.module == module) {
ALLOC_ZVAL(function);
reflection_function_factory(fptr, NULL, function TSRMLS_CC);
- add_assoc_zval_ex(return_value, func->fname, fname_len+1, function);
- func++;
- efree(lc_name);
+ add_assoc_zval(return_value, fptr->common.function_name, function);
}
+ zend_hash_move_forward_ex(CG(function_table), &iterator);
}
}
/* }}} */