diff options
author | Dmitry Stogov <dmitry@zend.com> | 2017-09-20 02:25:56 +0300 |
---|---|---|
committer | Dmitry Stogov <dmitry@zend.com> | 2017-09-20 02:25:56 +0300 |
commit | 44e0b79ac64b344fc1335c126e548f00d8308602 (patch) | |
tree | bcfc582b0d7a46b9798498fcb163079c7b9b8750 /ext | |
parent | c1dc10aaa5249ba54b6fa5bc043a80bd96f1c9e7 (diff) | |
download | php-git-44e0b79ac64b344fc1335c126e548f00d8308602.tar.gz |
Refactored array creation API. array_init() and array_init_size() are converted into macros calling zend_new_array(). They are not functions anymore and don't return any values.
Diffstat (limited to 'ext')
-rw-r--r-- | ext/dom/php_dom.c | 3 | ||||
-rw-r--r-- | ext/dom/xpath.c | 3 | ||||
-rw-r--r-- | ext/intl/breakiterator/breakiterator_class.cpp | 3 | ||||
-rw-r--r-- | ext/intl/calendar/calendar_class.cpp | 3 | ||||
-rw-r--r-- | ext/intl/msgformat/msgformat_format.c | 3 | ||||
-rw-r--r-- | ext/intl/timezone/timezone_class.cpp | 3 | ||||
-rw-r--r-- | ext/json/json_parser.tab.c | 6 | ||||
-rw-r--r-- | ext/libxml/libxml.c | 4 | ||||
-rw-r--r-- | ext/mbstring/mbstring.c | 6 | ||||
-rw-r--r-- | ext/mysqli/mysqli.c | 3 | ||||
-rw-r--r-- | ext/opcache/Optimizer/dfa_pass.c | 3 | ||||
-rw-r--r-- | ext/opcache/Optimizer/sccp.c | 6 | ||||
-rw-r--r-- | ext/pdo/pdo_stmt.c | 3 | ||||
-rw-r--r-- | ext/simplexml/simplexml.c | 6 | ||||
-rw-r--r-- | ext/soap/soap.c | 12 | ||||
-rw-r--r-- | ext/spl/spl_array.c | 3 | ||||
-rw-r--r-- | ext/spl/spl_dllist.c | 3 | ||||
-rw-r--r-- | ext/spl/spl_heap.c | 3 | ||||
-rw-r--r-- | ext/spl/spl_observer.c | 3 | ||||
-rw-r--r-- | ext/standard/browscap.c | 4 | ||||
-rw-r--r-- | ext/standard/streamsfuncs.c | 6 | ||||
-rw-r--r-- | ext/xsl/php_xsl.c | 6 | ||||
-rw-r--r-- | ext/xsl/xsltprocessor.c | 3 |
23 files changed, 34 insertions, 64 deletions
diff --git a/ext/dom/php_dom.c b/ext/dom/php_dom.c index 77f918ae9b..9892285cbb 100644 --- a/ext/dom/php_dom.c +++ b/ext/dom/php_dom.c @@ -1105,8 +1105,7 @@ zend_object *dom_xpath_objects_new(zend_class_entry *class_type) { dom_xpath_object *intern = ecalloc(1, sizeof(dom_xpath_object) + zend_object_properties_size(class_type)); - ALLOC_HASHTABLE(intern->registered_phpfunctions); - zend_hash_init(intern->registered_phpfunctions, 0, NULL, ZVAL_PTR_DTOR, 0); + intern->registered_phpfunctions = zend_new_array(0); intern->dom.prop_handler = &dom_xpath_prop_handlers; intern->dom.std.handlers = &dom_xpath_object_handlers; diff --git a/ext/dom/xpath.c b/ext/dom/xpath.c index 068ca61bfe..57d1c8796a 100644 --- a/ext/dom/xpath.c +++ b/ext/dom/xpath.c @@ -204,8 +204,7 @@ static void dom_xpath_ext_function_php(xmlXPathParserContextPtr ctxt, int nargs, xmlNode *nodep; dom_object *obj; if (intern->node_list == NULL) { - ALLOC_HASHTABLE(intern->node_list); - zend_hash_init(intern->node_list, 0, NULL, ZVAL_PTR_DTOR, 0); + intern->node_list = zend_new_array(0); } Z_ADDREF(retval); zend_hash_next_index_insert(intern->node_list, &retval); diff --git a/ext/intl/breakiterator/breakiterator_class.cpp b/ext/intl/breakiterator/breakiterator_class.cpp index ae9e258608..355072dec5 100644 --- a/ext/intl/breakiterator/breakiterator_class.cpp +++ b/ext/intl/breakiterator/breakiterator_class.cpp @@ -144,8 +144,7 @@ static HashTable *BreakIterator_get_debug_info(zval *object, int *is_temp) *is_temp = 1; - ALLOC_HASHTABLE(debug_info); - zend_hash_init(debug_info, 8, NULL, ZVAL_PTR_DTOR, 0); + debug_info = zend_new_array(8); bio = Z_INTL_BREAKITERATOR_P(object); biter = bio->biter; diff --git a/ext/intl/calendar/calendar_class.cpp b/ext/intl/calendar/calendar_class.cpp index 41d8dd4926..5c67051d84 100644 --- a/ext/intl/calendar/calendar_class.cpp +++ b/ext/intl/calendar/calendar_class.cpp @@ -154,8 +154,7 @@ static HashTable *Calendar_get_debug_info(zval *object, int *is_temp) *is_temp = 1; - ALLOC_HASHTABLE(debug_info); - zend_hash_init(debug_info, 8, NULL, ZVAL_PTR_DTOR, 0); + debug_info = zend_new_array(8); co = Z_INTL_CALENDAR_P(object); cal = co->ucal; diff --git a/ext/intl/msgformat/msgformat_format.c b/ext/intl/msgformat/msgformat_format.c index cb74a3fb1b..bfc9dbe3ac 100644 --- a/ext/intl/msgformat/msgformat_format.c +++ b/ext/intl/msgformat/msgformat_format.c @@ -41,8 +41,7 @@ static void msgfmt_do_format(MessageFormatter_object *mfo, zval *args, zval *ret count = zend_hash_num_elements(Z_ARRVAL_P(args)); - ALLOC_HASHTABLE(args_copy); - zend_hash_init(args_copy, count, NULL, ZVAL_PTR_DTOR, 0); + args_copy = zend_new_array(count); zend_hash_copy(args_copy, Z_ARRVAL_P(args), (copy_ctor_func_t)zval_add_ref); umsg_format_helper(mfo, args_copy, &formatted, &formatted_len); diff --git a/ext/intl/timezone/timezone_class.cpp b/ext/intl/timezone/timezone_class.cpp index b036de81cf..c6f4dd5447 100644 --- a/ext/intl/timezone/timezone_class.cpp +++ b/ext/intl/timezone/timezone_class.cpp @@ -295,8 +295,7 @@ static HashTable *TimeZone_get_debug_info(zval *object, int *is_temp) *is_temp = 1; - ALLOC_HASHTABLE(debug_info); - zend_hash_init(debug_info, 8, NULL, ZVAL_PTR_DTOR, 0); + debug_info = zend_new_array(8); to = Z_INTL_TIMEZONE_P(object); tz = to->utimezone; diff --git a/ext/json/json_parser.tab.c b/ext/json/json_parser.tab.c index c5247e5f04..5db1842900 100644 --- a/ext/json/json_parser.tab.c +++ b/ext/json/json_parser.tab.c @@ -1856,7 +1856,8 @@ yyreturn: static int php_json_parser_array_create(php_json_parser *parser, zval *array) { - return array_init(array); + array_init(array); + return SUCCESS; } static int php_json_parser_array_append(php_json_parser *parser, zval *array, zval *zvalue) @@ -1868,7 +1869,8 @@ static int php_json_parser_array_append(php_json_parser *parser, zval *array, zv static int php_json_parser_object_create(php_json_parser *parser, zval *object) { if (parser->scanner.options & PHP_JSON_OBJECT_AS_ARRAY) { - return array_init(object); + array_init(object); + return SUCCESS; } else { return object_init(object); } diff --git a/ext/libxml/libxml.c b/ext/libxml/libxml.c index d88860c4f3..c355ae2ba4 100644 --- a/ext/libxml/libxml.c +++ b/ext/libxml/libxml.c @@ -1042,9 +1042,7 @@ static PHP_FUNCTION(libxml_get_errors) xmlErrorPtr error; - if (array_init(return_value) == FAILURE) { - RETURN_FALSE; - } + array_init(return_value); if (LIBXML(error_list)) { diff --git a/ext/mbstring/mbstring.c b/ext/mbstring/mbstring.c index e9b567edfa..0bb18e9b57 100644 --- a/ext/mbstring/mbstring.c +++ b/ext/mbstring/mbstring.c @@ -3134,8 +3134,7 @@ MBSTRING_API HashTable *php_mb_convert_encoding_recursive(HashTable *input, cons php_error_docref(NULL, E_WARNING, "Cannot convert recursively referenced values"); return NULL; } - output = (HashTable *)emalloc(sizeof(HashTable)); - zend_hash_init(output, zend_hash_num_elements(input), NULL, ZVAL_PTR_DTOR, 0); + output = zend_new_array(zend_hash_num_elements(input)); ZEND_HASH_FOREACH_KEY_VAL(input, idx, key, entry) { /* convert key */ if (key) { @@ -3160,8 +3159,7 @@ MBSTRING_API HashTable *php_mb_convert_encoding_recursive(HashTable *input, cons case IS_ARRAY: chash = php_mb_convert_encoding_recursive(HASH_OF(entry), _to_encoding, _from_encodings); if (!chash) { - chash = (HashTable *)emalloc(sizeof(HashTable)); - zend_hash_init(chash, 0, NULL, ZVAL_PTR_DTOR, 0); + chash = zend_new_array(0); } ZVAL_ARR(&entry_tmp, chash); break; diff --git a/ext/mysqli/mysqli.c b/ext/mysqli/mysqli.c index b77fc8dec0..63065b5e90 100644 --- a/ext/mysqli/mysqli.c +++ b/ext/mysqli/mysqli.c @@ -424,8 +424,7 @@ HashTable *mysqli_object_get_debug_info(zval *object, int *is_temp) HashTable *retval, *props = obj->prop_handler; mysqli_prop_handler *entry; - ALLOC_HASHTABLE(retval); - ZEND_INIT_SYMTABLE_EX(retval, zend_hash_num_elements(props) + 1, 0); + retval = zend_new_array(zend_hash_num_elements(props) + 1); ZEND_HASH_FOREACH_PTR(props, entry) { zval rv, member; diff --git a/ext/opcache/Optimizer/dfa_pass.c b/ext/opcache/Optimizer/dfa_pass.c index 8ec4230848..b62b35c8b6 100644 --- a/ext/opcache/Optimizer/dfa_pass.c +++ b/ext/opcache/Optimizer/dfa_pass.c @@ -391,8 +391,7 @@ int zend_dfa_optimize_calls(zend_op_array *op_array, zend_ssa *ssa) zend_ulong idx; ZVAL_TRUE(&tmp); - dst = emalloc(sizeof(HashTable)); - zend_hash_init(dst, zend_hash_num_elements(src), NULL, ZVAL_PTR_DTOR, 0); + dst = zend_new_array(zend_hash_num_elements(src)); if (strict) { ZEND_HASH_FOREACH_VAL(src, val) { if (Z_TYPE_P(val) == IS_STRING) { diff --git a/ext/opcache/Optimizer/sccp.c b/ext/opcache/Optimizer/sccp.c index 0a97711ce9..1ece45d80c 100644 --- a/ext/opcache/Optimizer/sccp.c +++ b/ext/opcache/Optimizer/sccp.c @@ -103,8 +103,7 @@ typedef struct _sccp_ctx { static void empty_partial_array(zval *zv) { Z_TYPE_INFO_P(zv) = PARTIAL_ARRAY | (IS_TYPE_REFCOUNTED << Z_TYPE_FLAGS_SHIFT); - Z_ARR_P(zv) = (zend_array *) emalloc(sizeof(zend_array)); - zend_hash_init(Z_ARR_P(zv), 8, NULL, ZVAL_PTR_DTOR, 0); + Z_ARR_P(zv) = zend_new_array(8); } static void dup_partial_array(zval *dst, zval *src) @@ -116,8 +115,7 @@ static void dup_partial_array(zval *dst, zval *src) static void empty_partial_object(zval *zv) { Z_TYPE_INFO_P(zv) = PARTIAL_OBJECT | (IS_TYPE_REFCOUNTED << Z_TYPE_FLAGS_SHIFT); - Z_ARR_P(zv) = (zend_array *) emalloc(sizeof(zend_array)); - zend_hash_init(Z_ARR_P(zv), 8, NULL, ZVAL_PTR_DTOR, 0); + Z_ARR_P(zv) = zend_new_array(8); } static void dup_partial_object(zval *dst, zval *src) diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c index caf3ff1ef4..d65bf217c4 100644 --- a/ext/pdo/pdo_stmt.c +++ b/ext/pdo/pdo_stmt.c @@ -857,8 +857,7 @@ static int do_fetch(pdo_stmt_t *stmt, int do_bind, zval *return_value, enum pdo_ case PDO_FETCH_NUM: case PDO_FETCH_NAMED: if (!return_all) { - ZVAL_NEW_ARR(return_value); - zend_hash_init(Z_ARRVAL_P(return_value), stmt->column_count, NULL, ZVAL_PTR_DTOR, 0); + array_init_size(return_value, stmt->column_count); } else { array_init(return_value); } diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index 0ec2c86f4a..92d180cf8b 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -1133,14 +1133,12 @@ static HashTable *sxe_get_prop_hash(zval *object, int is_debug) /* {{{ */ sxe = Z_SXEOBJ_P(object); if (is_debug) { - ALLOC_HASHTABLE(rv); - zend_hash_init(rv, 0, NULL, ZVAL_PTR_DTOR, 0); + rv = zend_new_array(0); } else if (sxe->properties) { zend_hash_clean(sxe->properties); rv = sxe->properties; } else { - ALLOC_HASHTABLE(rv); - zend_hash_init(rv, 0, NULL, ZVAL_PTR_DTOR, 0); + rv = zend_new_array(0); sxe->properties = rv; } diff --git a/ext/soap/soap.c b/ext/soap/soap.c index 13bfce90b2..21deb4ec80 100644 --- a/ext/soap/soap.c +++ b/ext/soap/soap.c @@ -1223,8 +1223,7 @@ PHP_METHOD(SoapServer, SoapServer) service->version = version; service->type = SOAP_FUNCTIONS; service->soap_functions.functions_all = FALSE; - service->soap_functions.ft = emalloc(sizeof(HashTable)); - zend_hash_init(service->soap_functions.ft, 0, NULL, ZVAL_PTR_DTOR, 0); + service->soap_functions.ft = zend_new_array(0); if (Z_TYPE_P(wsdl) != IS_NULL) { service->sdl = get_sdl(getThis(), Z_STRVAL_P(wsdl), cache_wsdl); @@ -1415,8 +1414,7 @@ PHP_METHOD(SoapServer, addFunction) if (service->soap_functions.ft == NULL) { service->soap_functions.functions_all = FALSE; - service->soap_functions.ft = emalloc(sizeof(HashTable)); - zend_hash_init(service->soap_functions.ft, zend_hash_num_elements(Z_ARRVAL_P(function_name)), NULL, ZVAL_PTR_DTOR, 0); + service->soap_functions.ft = zend_new_array(zend_hash_num_elements(Z_ARRVAL_P(function_name))); } ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(function_name), tmp_function) { @@ -1455,8 +1453,7 @@ PHP_METHOD(SoapServer, addFunction) } if (service->soap_functions.ft == NULL) { service->soap_functions.functions_all = FALSE; - service->soap_functions.ft = emalloc(sizeof(HashTable)); - zend_hash_init(service->soap_functions.ft, 0, NULL, ZVAL_PTR_DTOR, 0); + service->soap_functions.ft = zend_new_array(0); } ZVAL_STR_COPY(&function_copy, f->common.function_name); @@ -2888,8 +2885,7 @@ PHP_METHOD(SoapClient, __call) free_soap_headers = 0; } else if (Z_TYPE_P(headers) == IS_OBJECT && instanceof_function(Z_OBJCE_P(headers), soap_header_class_entry)) { - soap_headers = emalloc(sizeof(HashTable)); - zend_hash_init(soap_headers, 0, NULL, ZVAL_PTR_DTOR, 0); + soap_headers = zend_new_array(0); zend_hash_next_index_insert(soap_headers, headers); Z_ADDREF_P(headers); free_soap_headers = 1; diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c index a45197114a..672f40e469 100644 --- a/ext/spl/spl_array.c +++ b/ext/spl/spl_array.c @@ -845,8 +845,7 @@ static HashTable* spl_array_get_debug_info(zval *obj, int *is_temp) /* {{{ */ HashTable *debug_info; *is_temp = 1; - ALLOC_HASHTABLE(debug_info); - ZEND_INIT_SYMTABLE_EX(debug_info, zend_hash_num_elements(intern->std.properties) + 1, 0); + debug_info = zend_new_array(zend_hash_num_elements(intern->std.properties) + 1); zend_hash_copy(debug_info, intern->std.properties, (copy_ctor_func_t) zval_add_ref); storage = &intern->array; diff --git a/ext/spl/spl_dllist.c b/ext/spl/spl_dllist.c index 667a6bad7b..af78e68f4d 100644 --- a/ext/spl/spl_dllist.c +++ b/ext/spl/spl_dllist.c @@ -506,8 +506,7 @@ static HashTable* spl_dllist_object_get_debug_info(zval *obj, int *is_temp) /* { rebuild_object_properties(&intern->std); } - ALLOC_HASHTABLE(debug_info); - zend_hash_init(debug_info, 1, NULL, ZVAL_PTR_DTOR, 0); + debug_info = zend_new_array(1); zend_hash_copy(debug_info, intern->std.properties, (copy_ctor_func_t) zval_add_ref); pnstr = spl_gen_private_prop_name(spl_ce_SplDoublyLinkedList, "flags", sizeof("flags")-1); diff --git a/ext/spl/spl_heap.c b/ext/spl/spl_heap.c index 06e4773677..3b179c523f 100644 --- a/ext/spl/spl_heap.c +++ b/ext/spl/spl_heap.c @@ -490,8 +490,7 @@ static HashTable* spl_heap_object_get_debug_info_helper(zend_class_entry *ce, zv rebuild_object_properties(&intern->std); } - ALLOC_HASHTABLE(debug_info); - ZEND_INIT_SYMTABLE_EX(debug_info, zend_hash_num_elements(intern->std.properties) + 1, 0); + debug_info = zend_new_array(zend_hash_num_elements(intern->std.properties) + 1); zend_hash_copy(debug_info, intern->std.properties, (copy_ctor_func_t) zval_add_ref); pnstr = spl_gen_private_prop_name(ce, "flags", sizeof("flags")-1); diff --git a/ext/spl/spl_observer.c b/ext/spl/spl_observer.c index de33bd5a6b..c6d366515b 100644 --- a/ext/spl/spl_observer.c +++ b/ext/spl/spl_observer.c @@ -295,8 +295,7 @@ static HashTable* spl_object_storage_debug_info(zval *obj, int *is_temp) /* {{{ props = Z_OBJPROP_P(obj); - ALLOC_HASHTABLE(debug_info); - ZEND_INIT_SYMTABLE_EX(debug_info, zend_hash_num_elements(props) + 1, 0); + debug_info = zend_new_array(zend_hash_num_elements(props) + 1); zend_hash_copy(debug_info, props, (copy_ctor_func_t)zval_add_ref); array_init(&storage); diff --git a/ext/standard/browscap.c b/ext/standard/browscap.c index 1b264f1eb9..cc126d77be 100644 --- a/ext/standard/browscap.c +++ b/ext/standard/browscap.c @@ -276,9 +276,7 @@ static HashTable *browscap_entry_to_array(browser_data *bdata, browscap_entry *e zval tmp; uint32_t i; - HashTable *ht; - ALLOC_HASHTABLE(ht); - zend_hash_init(ht, 8, NULL, ZVAL_PTR_DTOR, 0); + HashTable *ht = zend_new_array(8); ZVAL_STR(&tmp, browscap_convert_pattern(entry->pattern, 0)); zend_hash_str_add(ht, "browser_name_regex", sizeof("browser_name_regex")-1, &tmp); diff --git a/ext/standard/streamsfuncs.c b/ext/standard/streamsfuncs.c index 979a64b913..afd8088caf 100644 --- a/ext/standard/streamsfuncs.c +++ b/ext/standard/streamsfuncs.c @@ -665,8 +665,7 @@ static int stream_array_from_fd_set(zval *stream_array, fd_set *fds) if (Z_TYPE_P(stream_array) != IS_ARRAY) { return 0; } - ZVAL_NEW_ARR(&new_array); - zend_hash_init(Z_ARRVAL(new_array), zend_hash_num_elements(Z_ARRVAL_P(stream_array)), NULL, ZVAL_PTR_DTOR, 0); + array_init_size(&new_array, zend_hash_num_elements(Z_ARRVAL_P(stream_array))); ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(stream_array), num_ind, key, elem) { php_socket_t this_fd; @@ -714,8 +713,7 @@ static int stream_array_emulate_read_fd_set(zval *stream_array) if (Z_TYPE_P(stream_array) != IS_ARRAY) { return 0; } - ZVAL_NEW_ARR(&new_array); - zend_hash_init(Z_ARRVAL(new_array), zend_hash_num_elements(Z_ARRVAL_P(stream_array)), NULL, ZVAL_PTR_DTOR, 0); + array_init_size(&new_array, zend_hash_num_elements(Z_ARRVAL_P(stream_array))); ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(stream_array), elem) { ZVAL_DEREF(elem); diff --git a/ext/xsl/php_xsl.c b/ext/xsl/php_xsl.c index b7160232ef..61afc36099 100644 --- a/ext/xsl/php_xsl.c +++ b/ext/xsl/php_xsl.c @@ -113,10 +113,8 @@ zend_object *xsl_objects_new(zend_class_entry *class_type) zend_object_std_init(&intern->std, class_type); object_properties_init(&intern->std, class_type); - ALLOC_HASHTABLE(intern->parameter); - zend_hash_init(intern->parameter, 0, NULL, ZVAL_PTR_DTOR, 0); - ALLOC_HASHTABLE(intern->registered_phpfunctions); - zend_hash_init(intern->registered_phpfunctions, 0, NULL, ZVAL_PTR_DTOR, 0); + intern->parameter = zend_new_array(0); + intern->registered_phpfunctions = zend_new_array(0); intern->std.handlers = &xsl_object_handlers; return &intern->std; diff --git a/ext/xsl/xsltprocessor.c b/ext/xsl/xsltprocessor.c index 3970e267ba..02c436e340 100644 --- a/ext/xsl/xsltprocessor.c +++ b/ext/xsl/xsltprocessor.c @@ -343,8 +343,7 @@ static void xsl_ext_function_php(xmlXPathParserContextPtr ctxt, int nargs, int t xmlNode *nodep; dom_object *obj; if (intern->node_list == NULL) { - ALLOC_HASHTABLE(intern->node_list); - zend_hash_init(intern->node_list, 0, NULL, ZVAL_PTR_DTOR, 0); + intern->node_list = zend_new_array(0); } Z_ADDREF(retval); zend_hash_next_index_insert(intern->node_list, &retval); |