com php-src: Remove some usages of hashtable internals: ext/mysql/php_mysql.c ext/mysqli/mysqli.c ext/mysqlnd /mysqlnd_reverse_api.c
ext/mysqlnd/php_mysqlnd.c ext/pdo/pdo_dbh.c ext/pdo/pdo_stmt.c ext/pgsql/pgsq l.c

From: Date: Wed, 09 Apr 2014 10:31:21 +0000
Subject: com php-src: Remove some usages of hashtable internals: ext/mysql/php_mysql.c ext/mysqli/mysqli.c ext/mysqlnd /mysqlnd_reverse_api.c
ext/mysqlnd/php_mysqlnd.c ext/pdo/pdo_dbh.c ext/pdo/pdo_stmt.c ext/pgsql/pgsq l.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-76743@lists.php.net to get a copy of this message
Commit: eaf44ec397cc3286107166ce51bac03bf6bc8f83 Author: Nikita Popov <nikic@php.net> Mon, 7 Apr 2014 20:46:45 +0200 Parents: 6006a3ed5164b7a1e1c68482883c73b6716b10fc Branches: PHP-5.6 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=eaf44ec397cc3286107166ce51bac03bf6bc8f83 Log: Remove some usages of hashtable internals Changed paths: M ext/mysql/php_mysql.c M ext/mysqli/mysqli.c M ext/mysqlnd/mysqlnd_reverse_api.c M ext/mysqlnd/php_mysqlnd.c M ext/pdo/pdo_dbh.c M ext/pdo/pdo_stmt.c M ext/pgsql/pgsql.c Diff: diff --git a/ext/mysql/php_mysql.c b/ext/mysql/php_mysql.c index 3d092b2..daf712c 100644 --- a/ext/mysql/php_mysql.c +++ b/ext/mysql/php_mysql.c @@ -2173,19 +2173,12 @@ static void php_mysql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, long result_type, fci.symbol_table = NULL; fci.object_ptr = return_value; fci.retval_ptr_ptr = &retval_ptr; + fci.params = NULL; + fci.param_count = 0; + fci.no_separation = 1; + if (ctor_params && Z_TYPE_P(ctor_params) != IS_NULL) { - if (Z_TYPE_P(ctor_params) == IS_ARRAY) { - HashTable *htl = Z_ARRVAL_P(ctor_params); - Bucket *p; - - fci.param_count = 0; - fci.params = safe_emalloc(sizeof(zval*), htl->nNumOfElements, 0); - p = htl->pListHead; - while (p != NULL) { - fci.params[fci.param_count++] = (zval**)p->pData; - p = p->pListNext; - } - } else { + if (zend_fcall_info_args(&fci, ctor_params TSRMLS_CC) == FAILURE) { /* Two problems why we throw exceptions here: PHP is typeless * and hence passing one argument that's not an array could be * by mistake and the other way round is possible, too. The @@ -2195,11 +2188,7 @@ static void php_mysql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, long result_type, zend_throw_exception(zend_exception_get_default(TSRMLS_C), "Parameter ctor_params must be an array", 0 TSRMLS_CC); return; } - } else { - fci.param_count = 0; - fci.params = NULL; } - fci.no_separation = 1; fcc.initialized = 1; fcc.function_handler = ce->constructor; diff --git a/ext/mysqli/mysqli.c b/ext/mysqli/mysqli..c index 0cea68a..c819b97 100644 --- a/ext/mysqli/mysqli.c +++ b/ext/mysqli/mysqli.c @@ -1296,19 +1296,12 @@ void php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAMETERS, int override_flags fci.symbol_table = NULL; fci.object_ptr = return_value; fci.retval_ptr_ptr = &retval_ptr; + fci.params = NULL; + fci.param_count = 0; + fci.no_separation = 1; + if (ctor_params && Z_TYPE_P(ctor_params) != IS_NULL) { - if (Z_TYPE_P(ctor_params) == IS_ARRAY) { - HashTable *params_ht = Z_ARRVAL_P(ctor_params); - Bucket *p; - - fci.param_count = 0; - fci.params = safe_emalloc(sizeof(zval*), params_ht->nNumOfElements, 0); - p = params_ht->pListHead; - while (p != NULL) { - fci.params[fci.param_count++] = (zval**)p->pData; - p = p->pListNext; - } - } else { + if (zend_fcall_info_args(&fci, ctor_params TSRMLS_CC) == FAILURE) { /* Two problems why we throw exceptions here: PHP is typeless * and hence passing one argument that's not an array could be * by mistake and the other way round is possible, too. The @@ -1318,11 +1311,7 @@ void php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAMETERS, int override_flags zend_throw_exception(zend_exception_get_default(TSRMLS_C), "Parameter ctor_params must be an array", 0 TSRMLS_CC); return; } - } else { - fci.param_count = 0; - fci.params = NULL; } - fci.no_separation = 1; fcc.initialized = 1; fcc.function_handler = ce->constructor; diff --git a/ext/mysqlnd/mysqlnd_reverse_api.c b/ext/mysqlnd/mysqlnd_reverse_api.c index cd490fa..b461b49 100644 --- a/ext/mysqlnd/mysqlnd_reverse_api.c +++ b/ext/mysqlnd/mysqlnd_reverse_api..c @@ -61,7 +61,7 @@ PHPAPI void mysqlnd_reverse_api_register_api(MYSQLND_REVERSE_API * apiext TSRMLS_DC) { zend_hash_add(&mysqlnd_api_ext_ht, apiext->module->name, strlen(apiext->module->name) + 1, &apiext, - sizeof(MYSQLND_REVERSE_API), NULL); + sizeof(MYSQLND_REVERSE_API *), NULL); } /* }}} */ diff --git a/ext/mysqlnd/php_mysqlnd.c b/ext/mysqlnd/php_mysqlnd.c index 7712f1e..1a4e67f 100644 --- a/ext/mysqlnd/php_mysqlnd.c +++ b/ext/mysqlnd/php_mysqlnd.c @@ -107,17 +107,17 @@ static void mysqlnd_minfo_dump_api_plugins(smart_str * buffer TSRMLS_DC) { HashTable *ht = mysqlnd_reverse_api_get_api_list(TSRMLS_C); - Bucket *p; + HashPosition pos; + MYSQLND_REVERSE_API **ext; - p = ht->pListHead; - while(p != NULL) { - MYSQLND_REVERSE_API * ext = *(MYSQLND_REVERSE_API **) p->pData; + for (zend_hash_internal_pointer_reset_ex(ht, &pos); + zend_hash_get_current_data_ex(ht, (void **) &ext, &pos); + zend_hash_move_forward_ex(ht, &pos) + ) { if (buffer->len) { smart_str_appendc(buffer, ','); } - smart_str_appends(buffer, ext->module->name); - - p = p->pListNext; + smart_str_appends(buffer, (*ext)->module->name); } } /* }}} */ diff --git a/ext/pdo/pdo_dbh.c b/ext/pdo/pdo_dbh.c index d17867d..32e6e1b 100644 --- a/ext/pdo/pdo_dbh.c +++ b/ext/pdo/pdo_dbh.c @@ -468,23 +468,11 @@ static void pdo_stmt_construct(pdo_stmt_t *stmt, zval *object, zend_class_entry fci.object_ptr = object; fci.symbol_table = NULL; fci.retval_ptr_ptr = &retval; - if (ctor_args) { - HashTable *ht = Z_ARRVAL_P(ctor_args); - Bucket *p; - - fci.param_count = 0; - fci.params = safe_emalloc(sizeof(zval*), ht->nNumOfElements, 0); - p = ht->pListHead; - while (p != NULL) { - fci.params[fci.param_count++] = (zval**)p->pData; - p = p->pListNext; - } - } else { - fci.param_count = 0; - fci.params = NULL; - } + fci.params = NULL; fci.no_separation = 1; + zend_fcall_info_args(&fci, ctor_args TSRMLS_CC); + fcc.initialized = 1; fcc.function_handler = dbstmt_ce->constructor; fcc.calling_scope = EG(scope); diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c index 2735aed..2593d02 100644 --- a/ext/pdo/pdo_stmt.c +++ b/ext/pdo/pdo_stmt.c @@ -757,23 +757,11 @@ static int do_fetch_class_prepare(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */ fci->function_name = NULL; fci->symbol_table = NULL; fci->retval_ptr_ptr = &stmt->fetch.cls.retval_ptr; - if (stmt->fetch.cls.ctor_args) { - HashTable *ht = Z_ARRVAL_P(stmt->fetch.cls.ctor_args); - Bucket *p; - - fci->param_count = 0; - fci->params = safe_emalloc(sizeof(zval**), ht->nNumOfElements, 0); - p = ht->pListHead; - while (p != NULL) { - fci->params[fci->param_count++] = (zval**)p->pData; - p = p->pListNext; - } - } else { - fci->param_count = 0; - fci->params = NULL; - } + fci->params = NULL; fci->no_separation = 1; + zend_fcall_info_args(fci, stmt->fetch.cls.ctor_args TSRMLS_CC); + fcc->initialized = 1; fcc->function_handler = ce->constructor; fcc->calling_scope = EG(scope); diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c index f5e142a..d36901d 100644 --- a/ext/pgsql/pgsql.c +++ b/ext/pgsql/pgsql.c @@ -2793,33 +2793,22 @@ static void php_pgsql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, long result_type, fci.symbol_table = NULL; fci.object_ptr = return_value; fci.retval_ptr_ptr = &retval_ptr; + fci.params = NULL; + fci.param_count = 0; + fci.no_separation = 1; + if (ctor_params && Z_TYPE_P(ctor_params) != IS_NULL) { - if (Z_TYPE_P(ctor_params) == IS_ARRAY) { - HashTable *ht = Z_ARRVAL_P(ctor_params); - Bucket *p; - - fci.param_count = 0; - fci.params = safe_emalloc(sizeof(zval***), ht->nNumOfElements, 0); - p = ht->pListHead; - while (p != NULL) { - fci.params[fci.param_count++] = (zval**)p->pData; - p = p->pListNext; - } - } else { + if (zend_fcall_info_args(&fci, ctor_params TSRMLS_CC) == FAILURE) { /* Two problems why we throw exceptions here: PHP is typeless * and hence passing one argument that's not an array could be - * by mistake and the other way round is possible, too. The + * by mistake and the other way round is possible, too. The * single value is an array. Also we'd have to make that one * argument passed by reference. */ zend_throw_exception(zend_exception_get_default(TSRMLS_C), "Parameter ctor_params must be an array", 0 TSRMLS_CC); return; } - } else { - fci.param_count = 0; - fci.params = NULL; } - fci.no_separation = 1; fcc.initialized = 1; fcc.function_handler = ce->constructor;

« previous php.cvs (#76743) next »