diff options
| author | Nikita Popov <nikic@php.net> | 2014-04-07 20:46:45 +0200 | 
|---|---|---|
| committer | Nikita Popov <nikic@php.net> | 2014-04-09 12:31:21 +0200 | 
| commit | eaf44ec397cc3286107166ce51bac03bf6bc8f83 (patch) | |
| tree | 24c6ddcb2ae1072cee6af97d7cb07e317485a82c | |
| parent | 6006a3ed5164b7a1e1c68482883c73b6716b10fc (diff) | |
| download | php-git-eaf44ec397cc3286107166ce51bac03bf6bc8f83.tar.gz | |
Remove some usages of hashtable internals
| -rw-r--r-- | ext/mysql/php_mysql.c | 21 | ||||
| -rw-r--r-- | ext/mysqli/mysqli.c | 21 | ||||
| -rw-r--r-- | ext/mysqlnd/mysqlnd_reverse_api.c | 2 | ||||
| -rw-r--r-- | ext/mysqlnd/php_mysqlnd.c | 14 | ||||
| -rw-r--r-- | ext/pdo/pdo_dbh.c | 18 | ||||
| -rw-r--r-- | ext/pdo/pdo_stmt.c | 18 | ||||
| -rw-r--r-- | ext/pgsql/pgsql.c | 23 | 
7 files changed, 30 insertions, 87 deletions
diff --git a/ext/mysql/php_mysql.c b/ext/mysql/php_mysql.c index 3d092b2d6a..daf712cd0d 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 0cea68a33f..c819b976ea 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 cd490fa62c..b461b49427 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 7712f1ecb8..1a4e67f5eb 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 d17867d1f9..32e6e1bdd0 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 2735aede41..2593d02e96 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 f5e142a775..d36901d8c1 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;  | 
