Skip to content

Commit b70f24e

Browse files
author
Phalcon
committed
Merge pull request #1603 from sjinks/1.2.5
Fix compilation errors in zim_Phalcon_Mvc_Model_Row_toArray()
2 parents ab3fac1 + 502a76d commit b70f24e

File tree

1 file changed

+5
-22
lines changed

1 file changed

+5
-22
lines changed

ext/mvc/model/row.c

+5-22
Original file line numberDiff line numberDiff line change
@@ -149,31 +149,14 @@ PHP_METHOD(Phalcon_Mvc_Model_Row, offsetUnset){
149149
*/
150150
PHP_METHOD(Phalcon_Mvc_Model_Row, toArray){
151151

152-
zval *properties, *key = NULL, *value = NULL;
153-
HashTable *ah0;
154-
HashPosition hp0;
155-
zval **hd;
152+
HashTable *properties;
156153

157-
PHALCON_MM_GROW();
158-
159154
properties = Z_OBJ_HT_P(this_ptr)->get_properties(this_ptr TSRMLS_CC);
160155

161-
if (properties == NULL) {
162-
RETURN_MM_FALSE;
163-
}
164-
165-
array_init(return_value);
166-
167-
zend_hash_internal_pointer_reset_ex(properties, &hp0);
168-
while (zend_hash_get_current_data_ex(properties, (void**) &hd, &hp0) == SUCCESS) {
169-
PHALCON_GET_HKEY(key, ah0, hp0);
170-
PHALCON_GET_HVALUE(value);
171-
172-
phalcon_array_update_zval(&return_value, key, &value, PH_COPY | PH_SEPARATE);
173-
174-
zend_hash_move_forward_ex(ah0, &hp0);
156+
if (!properties) {
157+
RETURN_FALSE;
175158
}
176159

177-
RETURN_MM();
160+
array_init_size(return_value, zend_hash_num_elements(properties));
161+
zend_hash_copy(Z_ARRVAL_P(return_value), properties, (copy_ctor_func_t)zval_add_ref, NULL, sizeof(zval*));
178162
}
179-

0 commit comments

Comments
 (0)