com php-src: Merge remote-tracking branch 'origin/PHP-5.6' into str_size_and_int64_56_backport: Zend/zend _hash.c Zend/zend_hash.h
ext/mysql/php_mysql.c ext/mysqli/mysqli.c ext/mysqlnd/php_mysqlnd.c ext/ pdo/pdo_dbh.c ext/pdo/pdo_stmt.c ext/pgsql/pgsql. c ext/spl/spl_iterators.c
ext/standard/array.c ext/ standard/php_array.h ext/standard/tests/strings/substr_ compare.phpt
| From: | Anatol Belski | Date: | Thu, 10 Apr 2014 08:49:48 +0000 |
| Subject: | com php-src: Merge remote-tracking branch 'origin/PHP-5.6' into str_size_and_int64_56_backport: Zend/zend _hash.c Zend/zend_hash.h ext/mysql/php_mysql.c ext/mysqli/mysqli.c ext/mysqlnd/php_mysqlnd.c ext/ pdo/pdo_dbh.c ext/pdo/pdo_stmt.c ext/pgsql/pgsql. c ext/spl/spl_iterators.c ext/standard/array.c ext/ standard/php_array.h ext/standard/tests/strings/substr_ compare.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-76770@lists.php.net to get a copy of this message | ||
Commit: af53cc6799221ac1ef48d028c5098838f445afd4
Author: Anatol Belski <ab@php.net> Thu, 10 Apr 2014 10:49:48 +0200
Parents: abad64c50e0ab36d23be4feb465fb5b3a8099a36 3204ad5858a5abc50b11b8527d22c82eb07a80cc
Branches: str_size_and_int64_56_backport
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=af53cc6799221ac1ef48d028c5098838f445afd4
Log:
Merge remote-tracking branch 'origin/PHP-5.6' into str_size_and_int64_56_backport
* origin/PHP-5.6:
fix typo
fix typo
fix typo
add a NEWS block for beta2
add missing entries to NEWS
abstract namespace for unix sockets is a linux only feature
Don't test for specific non-zero substr_compare() return value
Add only_integer_keys option to zend_hash_reindex
Don't always separate splice replacement array
Add zend_hash_splice
Add zend_hash_reindex
Remove some usages of hashtable internals
Updated NEWS
fixed bug66702 : regexiterator's invert flag doesn't work as expected
Conflicts:
Zend/zend_hash.c
ext/spl/spl_iterators.c
ext/standard/array.c
ext/standard/php_array.h
Bugs:
https://bugs.php.net/66702
Changed paths:
MM Zend/zend_hash.c
MM Zend/zend_hash.h
MM ext/mysql/php_mysql.c
MM ext/mysqli/mysqli.c
MM ext/mysqlnd/php_mysqlnd.c
MM ext/pdo/pdo_dbh.c
MM ext/pdo/pdo_stmt.c
MM ext/pgsql/pgsql.c
MM ext/spl/spl_iterators.c
MM ext/standard/array.c
MM ext/standard/php_array.h
MM ext/standard/tests/strings/substr_compare.phpt
diff --cc Zend/zend_hash.c index f61bcf4,3096313..558fbe8 --- a/Zend/zend_hash.c +++ b/Zend/zend_hash.c @@@ -476,9 -480,33 +480,33 @@@ ZEND_API int zend_hash_rehash(HashTabl return SUCCESS; } + ZEND_API void zend_hash_reindex(HashTable *ht, zend_bool only_integer_keys) { + Bucket *p; - uint nIndex; - ulong offset = 0; ++ zend_uint_t nIndex; ++ zend_uint_t offset = 0; + + IS_CONSISTENT(ht); + if (UNEXPECTED(ht->nNumOfElements == 0)) { + return; + } + + memset(ht->arBuckets, 0, ht->nTableSize * sizeof(Bucket *)); + for (p = ht->pListHead; p != NULL; p = p->pListNext) { + if (!only_integer_keys || p->nKeyLength == 0) { + p->h = offset++; + p->nKeyLength = 0; + } + + nIndex = p->h & ht->nTableMask; + CONNECT_TO_BUCKET_DLLIST(p, ht->arBuckets[nIndex]); + ht->arBuckets[nIndex] = p; + } + ht->nNextFreeElement = offset; + } + -ZEND_API int zend_hash_del_key_or_index(HashTable *ht, const char *arKey, uint nKeyLength, ulong h, int flag) +ZEND_API int zend_hash_del_key_or_index(HashTable *ht, const char *arKey, zend_size_t nKeyLength, zend_uint_t h, int flag) { - uint nIndex; + zend_uint_t nIndex; Bucket *p; IS_CONSISTENT(ht); diff --cc Zend/zend_hash.h index 22989a0,03f83df..08fccab --- a/Zend/zend_hash.h +++ b/Zend/zend_hash.h @@@ -224,9 -224,14 +224,14 @@@ ZEND_API int zend_hash_minmax(const Has #define zend_hash_merge(target, source, pCopyConstructor, tmp, size, overwrite) \ _zend_hash_merge(target, source, pCopyConstructor, tmp, size, overwrite ZEND_FILE_LINE_CC) -ZEND_API int zend_hash_num_elements(const HashTable *ht); +ZEND_API zend_uint_t zend_hash_num_elements(const HashTable *ht); ZEND_API int zend_hash_rehash(HashTable *ht); + ZEND_API void zend_hash_reindex(HashTable *ht, zend_bool only_integer_keys); + + ZEND_API void _zend_hash_splice(HashTable *ht, uint nDataSize, copy_ctor_func_t pCopyConstructor, uint offset, uint length, void **list, uint list_count, HashTable *removed ZEND_FILE_LINE_DC); + #define zend_hash_splice(ht, nDataSize, pCopyConstructor, offset, length, list, list_count, removed) \ + _zend_hash_splice(ht, nDataSize, pCopyConstructor, offset, length, list, list_count, removed ZEND_FILE_LINE_CC) /* * DJBX33A (Daniel J. Bernstein, Times 33 with Addition) diff --cc ext/spl/spl_iterators.c index fab889e,679fc85..4be7631 --- a/ext/spl/spl_iterators.c +++ b/ext/spl/spl_iterators.c @@@ -2057,7 -2055,7 +2057,7 @@@ SPL_METHOD(RegexIterator, accept } if (intern->u.regex.flags & REGIT_INVERTED) { - RETVAL_BOOL(Z_IVAL_P(return_value)); - RETVAL_BOOL(! Z_LVAL_P(return_value)); ++ RETVAL_BOOL(! Z_IVAL_P(return_value)); } if (use_copy) { @@@ -3693,12 -3691,13 +3693,13 @@@ PHP_MINIT_FUNCTION(spl_iterators REGISTER_SPL_SUB_CLASS_EX(InfiniteIterator, IteratorIterator, spl_dual_it_new, spl_funcs_InfiniteIterator); #if HAVE_PCRE || HAVE_BUNDLED_PCRE REGISTER_SPL_SUB_CLASS_EX(RegexIterator, FilterIterator, spl_dual_it_new, spl_funcs_RegexIterator); - REGISTER_SPL_CLASS_CONST_LONG(RegexIterator, "USE_KEY", REGIT_USE_KEY); - REGISTER_SPL_CLASS_CONST_LONG(RegexIterator, "INVERT_MATCH",REGIT_INVERTED); - REGISTER_SPL_CLASS_CONST_LONG(RegexIterator, "MATCH", REGIT_MODE_MATCH); - REGISTER_SPL_CLASS_CONST_LONG(RegexIterator, "GET_MATCH", REGIT_MODE_GET_MATCH); - REGISTER_SPL_CLASS_CONST_LONG(RegexIterator, "ALL_MATCHES", REGIT_MODE_ALL_MATCHES); - REGISTER_SPL_CLASS_CONST_LONG(RegexIterator, "SPLIT", REGIT_MODE_SPLIT); - REGISTER_SPL_CLASS_CONST_LONG(RegexIterator, "REPLACE", REGIT_MODE_REPLACE); + REGISTER_SPL_CLASS_CONST_INT(RegexIterator, "USE_KEY", REGIT_USE_KEY); ++ REGISTER_SPL_CLASS_CONST_INT(RegexIterator, "INVERT_MATCH",REGIT_INVERTED); + REGISTER_SPL_CLASS_CONST_INT(RegexIterator, "MATCH", REGIT_MODE_MATCH); + REGISTER_SPL_CLASS_CONST_INT(RegexIterator, "GET_MATCH", REGIT_MODE_GET_MATCH); + REGISTER_SPL_CLASS_CONST_INT(RegexIterator, "ALL_MATCHES", REGIT_MODE_ALL_MATCHES); + REGISTER_SPL_CLASS_CONST_INT(RegexIterator, "SPLIT", REGIT_MODE_SPLIT); + REGISTER_SPL_CLASS_CONST_INT(RegexIterator, "REPLACE", REGIT_MODE_REPLACE); REGISTER_SPL_PROPERTY(RegexIterator, "replacement", 0); REGISTER_SPL_SUB_CLASS_EX(RecursiveRegexIterator, RegexIterator, spl_dual_it_new, spl_funcs_RecursiveRegexIterator); REGISTER_SPL_IMPLEMENTS(RecursiveRegexIterator, RecursiveIterator); diff --cc ext/standard/array.c index 1b6da06,6c3be81..646d122 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@@ -1816,93 -1809,15 +1810,15 @@@ PHP_FUNCTION(shuffle } /* }}} */ - PHPAPI HashTable* php_splice(HashTable *in_hash, php_int_t offset, php_int_t length, zval ***list, php_int_t list_count, HashTable **removed) /* {{{ */ -PHPAPI void php_splice(HashTable *ht, zend_uint offset, zend_uint length, zval ***list, zend_uint list_count, HashTable *removed TSRMLS_DC) /* {{{ */ ++PHPAPI void php_splice(HashTable *ht, php_uint_t offset, php_size_t length, zval ***list, php_size_t list_count, HashTable *removed TSRMLS_DC) /* {{{ */ { - HashTable *out_hash = NULL; /* Output hashtable */ - php_int_t num_in, /* Number of entries in the input hashtable */ - pos, /* Current position in the hashtable */ - i; /* Loop counter */ - Bucket *p; /* Pointer to hash bucket */ - zval *entry; /* Hash entry */ - - /* If input hash doesn't exist, we have nothing to do */ - if (!in_hash) { - return NULL; - } - - /* Get number of entries in the input hash */ - num_in = zend_hash_num_elements(in_hash); + zend_hash_splice(ht, sizeof(zval *), (copy_ctor_func_t) zval_add_ref, offset, length, (void **) list, list_count, removed); - /* Clamp the offset.. */ - if (offset > num_in) { - offset = num_in; - } else if (offset < 0 && (offset = (num_in + offset)) < 0) { - offset = 0; - } - - /* ..and the length */ - if (length < 0) { - length = num_in - offset + length; - } else if (((php_uint_t)offset + (php_uint_t)length) > (php_uint_t)num_in) { - length = num_in - offset; - } - - /* Create and initialize output hash */ - ALLOC_HASHTABLE(out_hash); - zend_hash_init(out_hash, (length > 0 ? num_in - length : 0) + list_count, NULL, ZVAL_PTR_DTOR, 0); - - /* Start at the beginning of the input hash and copy entries to output hash until offset is reached */ - for (pos = 0, p = in_hash->pListHead; pos < offset && p ; pos++, p = p->pListNext) { - /* Get entry and increase reference count */ - entry = *((zval **)p->pData); - Z_ADDREF_P(entry); - - /* Update output hash depending on key type */ - if (p->nKeyLength == 0) { - zend_hash_next_index_insert(out_hash, &entry, sizeof(zval *), NULL); - } else { - zend_hash_quick_update(out_hash, p->arKey, p->nKeyLength, p->h, &entry, sizeof(zval *), NULL); - } - } - - /* If hash for removed entries exists, go until offset+length and copy the entries to it */ - if (removed != NULL) { - for ( ; pos < offset + length && p; pos++, p = p->pListNext) { - entry = *((zval **)p->pData); - Z_ADDREF_P(entry); - if (p->nKeyLength == 0) { - zend_hash_next_index_insert(*removed, &entry, sizeof(zval *), NULL); - } else { - zend_hash_quick_update(*removed, p->arKey, p->nKeyLength, p->h, &entry, sizeof(zval *), NULL); - } - } - } else { /* otherwise just skip those entries */ - for ( ; pos < offset + length && p; pos++, p = p->pListNext); - } - - /* If there are entries to insert.. */ - if (list != NULL) { - /* ..for each one, create a new zval, copy entry into it and copy it into the output hash */ - for (i = 0; i < list_count; i++) { - entry = *list[i]; - Z_ADDREF_P(entry); - zend_hash_next_index_insert(out_hash, &entry, sizeof(zval *), NULL); - } - } + zend_hash_internal_pointer_reset(ht); - /* Copy the remaining input hash entries to the output hash */ - for ( ; p ; p = p->pListNext) { - entry = *((zval **)p->pData); - Z_ADDREF_P(entry); - if (p->nKeyLength == 0) { - zend_hash_next_index_insert(out_hash, &entry, sizeof(zval *), NULL); - } else { - zend_hash_quick_update(out_hash, p->arKey, p->nKeyLength, p->h, &entry, sizeof(zval *), NULL); - } + if (ht == &EG(symbol_table)) { + zend_reset_all_cv(&EG(symbol_table) TSRMLS_CC); } - - zend_hash_internal_pointer_reset(out_hash); - return out_hash; } /* }}} */ @@@ -2054,19 -1942,17 +1943,17 @@@ PHP_FUNCTION(array_unshift PHP_FUNCTION(array_splice) { zval *array, /* Input array */ - *repl_array = NULL, /* Replacement array */ + **repl_array = NULL, /* Replacement array */ ***repl = NULL; /* Replacement elements */ - HashTable *new_hash = NULL, /* Output array's hash */ - **rem_hash = NULL; /* Removed elements' hash */ - HashTable old_hash; + HashTable *rem_hash = NULL; /* Removed elements' hash */ Bucket *p; /* Bucket used for traversing hash */ - long i, - offset, - length = 0, - repl_num = 0; /* Number of replacement elements */ - int num_in; /* Number of elements in the input array */ + php_int_t i; + php_int_t offset, + length = 0; + php_int_t repl_num = 0; /* Number of replacement elements */ + php_int_t num_in; /* Number of elements in the input array */ - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ai|iz/", &array, &offset, &length, &repl_array) == FAILURE) { - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "al|lZ", &array, &offset, &length, &repl_array) == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ai|iZ", &array, &offset, &length, &repl_array) == FAILURE) { return; } @@@ -2687,12 -2561,10 +2562,10 @@@ PHP_FUNCTION(array_pad zval *input; /* Input array */ zval *pad_value; /* Padding value obviously */ zval ***pads; /* Array to pass to splice */ - HashTable *new_hash;/* Return value from splice */ - HashTable old_hash; - long pad_size; /* Size to pad to */ - long pad_size_abs; /* Absolute value of pad_size */ - int input_size; /* Size of the input array */ - int num_pads; /* How many pads do we need */ + php_int_t pad_size; /* Size to pad to */ + php_int_t pad_size_abs; /* Absolute value of pad_size */ - int input_size; /* Size of the input array */ - php_int_t num_pads; /* How many pads do we need */ ++ php_int_t input_size; /* Size of the input array */ ++ php_int_t num_pads; /* How many pads do we need */ int do_pad; /* Whether we should do padding at all */ int i; diff --cc ext/standard/php_array.h index 4b69d19,deddeb4..2f470c2 --- a/ext/standard/php_array.h +++ b/ext/standard/php_array.h @@@ -103,7 -103,7 +103,7 @@@ PHP_FUNCTION(array_key_exists) PHP_FUNCTION(array_chunk); PHP_FUNCTION(array_combine); - PHPAPI HashTable* php_splice(HashTable *, php_int_t, php_int_t, zval ***, php_int_t, HashTable **); -PHPAPI void php_splice(HashTable *ht, zend_uint offset, zend_uint length, zval ***list, zend_uint list_count, HashTable *removed TSRMLS_DC); ++PHPAPI void php_splice(HashTable *ht, php_uint_t offset, php_size_t length, zval ***list, php_size_t list_count, HashTable *removed TSRMLS_DC); PHPAPI int php_array_merge(HashTable *dest, HashTable *src, int recursive TSRMLS_DC); PHPAPI int php_array_replace_recursive(HashTable *dest, HashTable *src TSRMLS_DC); PHPAPI int php_multisort_compare(const void *a, const void *b TSRMLS_DC);
diff --cc Zend/zend_hash.c index f61bcf4,3096313..558fbe8 --- a/Zend/zend_hash.c +++ b/Zend/zend_hash.c @@@ -476,9 -480,33 +480,33 @@@ ZEND_API int zend_hash_rehash(HashTabl return SUCCESS; } + ZEND_API void zend_hash_reindex(HashTable *ht, zend_bool only_integer_keys) { + Bucket *p; - uint nIndex; - ulong offset = 0; ++ zend_uint_t nIndex; ++ zend_uint_t offset = 0; + + IS_CONSISTENT(ht); + if (UNEXPECTED(ht->nNumOfElements == 0)) { + return; + } + + memset(ht->arBuckets, 0, ht->nTableSize * sizeof(Bucket *)); + for (p = ht->pListHead; p != NULL; p = p->pListNext) { + if (!only_integer_keys || p->nKeyLength == 0) { + p->h = offset++; + p->nKeyLength = 0; + } + + nIndex = p->h & ht->nTableMask; + CONNECT_TO_BUCKET_DLLIST(p, ht->arBuckets[nIndex]); + ht->arBuckets[nIndex] = p; + } + ht->nNextFreeElement = offset; + } + -ZEND_API int zend_hash_del_key_or_index(HashTable *ht, const char *arKey, uint nKeyLength, ulong h, int flag) +ZEND_API int zend_hash_del_key_or_index(HashTable *ht, const char *arKey, zend_size_t nKeyLength, zend_uint_t h, int flag) { - uint nIndex; + zend_uint_t nIndex; Bucket *p; IS_CONSISTENT(ht); diff --cc Zend/zend_hash.h index 22989a0,03f83df..08fccab --- a/Zend/zend_hash.h +++ b/Zend/zend_hash.h @@@ -224,9 -224,14 +224,14 @@@ ZEND_API int zend_hash_minmax(const Has #define zend_hash_merge(target, source, pCopyConstructor, tmp, size, overwrite) \ _zend_hash_merge(target, source, pCopyConstructor, tmp, size, overwrite ZEND_FILE_LINE_CC) -ZEND_API int zend_hash_num_elements(const HashTable *ht); +ZEND_API zend_uint_t zend_hash_num_elements(const HashTable *ht); ZEND_API int zend_hash_rehash(HashTable *ht); + ZEND_API void zend_hash_reindex(HashTable *ht, zend_bool only_integer_keys); + + ZEND_API void _zend_hash_splice(HashTable *ht, uint nDataSize, copy_ctor_func_t pCopyConstructor, uint offset, uint length, void **list, uint list_count, HashTable *removed ZEND_FILE_LINE_DC); + #define zend_hash_splice(ht, nDataSize, pCopyConstructor, offset, length, list, list_count, removed) \ + _zend_hash_splice(ht, nDataSize, pCopyConstructor, offset, length, list, list_count, removed ZEND_FILE_LINE_CC) /* * DJBX33A (Daniel J. Bernstein, Times 33 with Addition) diff --cc ext/spl/spl_iterators.c index fab889e,679fc85..4be7631 --- a/ext/spl/spl_iterators.c +++ b/ext/spl/spl_iterators.c @@@ -2057,7 -2055,7 +2057,7 @@@ SPL_METHOD(RegexIterator, accept } if (intern->u.regex.flags & REGIT_INVERTED) { - RETVAL_BOOL(Z_IVAL_P(return_value)); - RETVAL_BOOL(! Z_LVAL_P(return_value)); ++ RETVAL_BOOL(! Z_IVAL_P(return_value)); } if (use_copy) { @@@ -3693,12 -3691,13 +3693,13 @@@ PHP_MINIT_FUNCTION(spl_iterators REGISTER_SPL_SUB_CLASS_EX(InfiniteIterator, IteratorIterator, spl_dual_it_new, spl_funcs_InfiniteIterator); #if HAVE_PCRE || HAVE_BUNDLED_PCRE REGISTER_SPL_SUB_CLASS_EX(RegexIterator, FilterIterator, spl_dual_it_new, spl_funcs_RegexIterator); - REGISTER_SPL_CLASS_CONST_LONG(RegexIterator, "USE_KEY", REGIT_USE_KEY); - REGISTER_SPL_CLASS_CONST_LONG(RegexIterator, "INVERT_MATCH",REGIT_INVERTED); - REGISTER_SPL_CLASS_CONST_LONG(RegexIterator, "MATCH", REGIT_MODE_MATCH); - REGISTER_SPL_CLASS_CONST_LONG(RegexIterator, "GET_MATCH", REGIT_MODE_GET_MATCH); - REGISTER_SPL_CLASS_CONST_LONG(RegexIterator, "ALL_MATCHES", REGIT_MODE_ALL_MATCHES); - REGISTER_SPL_CLASS_CONST_LONG(RegexIterator, "SPLIT", REGIT_MODE_SPLIT); - REGISTER_SPL_CLASS_CONST_LONG(RegexIterator, "REPLACE", REGIT_MODE_REPLACE); + REGISTER_SPL_CLASS_CONST_INT(RegexIterator, "USE_KEY", REGIT_USE_KEY); ++ REGISTER_SPL_CLASS_CONST_INT(RegexIterator, "INVERT_MATCH",REGIT_INVERTED); + REGISTER_SPL_CLASS_CONST_INT(RegexIterator, "MATCH", REGIT_MODE_MATCH); + REGISTER_SPL_CLASS_CONST_INT(RegexIterator, "GET_MATCH", REGIT_MODE_GET_MATCH); + REGISTER_SPL_CLASS_CONST_INT(RegexIterator, "ALL_MATCHES", REGIT_MODE_ALL_MATCHES); + REGISTER_SPL_CLASS_CONST_INT(RegexIterator, "SPLIT", REGIT_MODE_SPLIT); + REGISTER_SPL_CLASS_CONST_INT(RegexIterator, "REPLACE", REGIT_MODE_REPLACE); REGISTER_SPL_PROPERTY(RegexIterator, "replacement", 0); REGISTER_SPL_SUB_CLASS_EX(RecursiveRegexIterator, RegexIterator, spl_dual_it_new, spl_funcs_RecursiveRegexIterator); REGISTER_SPL_IMPLEMENTS(RecursiveRegexIterator, RecursiveIterator); diff --cc ext/standard/array.c index 1b6da06,6c3be81..646d122 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@@ -1816,93 -1809,15 +1810,15 @@@ PHP_FUNCTION(shuffle } /* }}} */ - PHPAPI HashTable* php_splice(HashTable *in_hash, php_int_t offset, php_int_t length, zval ***list, php_int_t list_count, HashTable **removed) /* {{{ */ -PHPAPI void php_splice(HashTable *ht, zend_uint offset, zend_uint length, zval ***list, zend_uint list_count, HashTable *removed TSRMLS_DC) /* {{{ */ ++PHPAPI void php_splice(HashTable *ht, php_uint_t offset, php_size_t length, zval ***list, php_size_t list_count, HashTable *removed TSRMLS_DC) /* {{{ */ { - HashTable *out_hash = NULL; /* Output hashtable */ - php_int_t num_in, /* Number of entries in the input hashtable */ - pos, /* Current position in the hashtable */ - i; /* Loop counter */ - Bucket *p; /* Pointer to hash bucket */ - zval *entry; /* Hash entry */ - - /* If input hash doesn't exist, we have nothing to do */ - if (!in_hash) { - return NULL; - } - - /* Get number of entries in the input hash */ - num_in = zend_hash_num_elements(in_hash); + zend_hash_splice(ht, sizeof(zval *), (copy_ctor_func_t) zval_add_ref, offset, length, (void **) list, list_count, removed); - /* Clamp the offset.. */ - if (offset > num_in) { - offset = num_in; - } else if (offset < 0 && (offset = (num_in + offset)) < 0) { - offset = 0; - } - - /* ..and the length */ - if (length < 0) { - length = num_in - offset + length; - } else if (((php_uint_t)offset + (php_uint_t)length) > (php_uint_t)num_in) { - length = num_in - offset; - } - - /* Create and initialize output hash */ - ALLOC_HASHTABLE(out_hash); - zend_hash_init(out_hash, (length > 0 ? num_in - length : 0) + list_count, NULL, ZVAL_PTR_DTOR, 0); - - /* Start at the beginning of the input hash and copy entries to output hash until offset is reached */ - for (pos = 0, p = in_hash->pListHead; pos < offset && p ; pos++, p = p->pListNext) { - /* Get entry and increase reference count */ - entry = *((zval **)p->pData); - Z_ADDREF_P(entry); - - /* Update output hash depending on key type */ - if (p->nKeyLength == 0) { - zend_hash_next_index_insert(out_hash, &entry, sizeof(zval *), NULL); - } else { - zend_hash_quick_update(out_hash, p->arKey, p->nKeyLength, p->h, &entry, sizeof(zval *), NULL); - } - } - - /* If hash for removed entries exists, go until offset+length and copy the entries to it */ - if (removed != NULL) { - for ( ; pos < offset + length && p; pos++, p = p->pListNext) { - entry = *((zval **)p->pData); - Z_ADDREF_P(entry); - if (p->nKeyLength == 0) { - zend_hash_next_index_insert(*removed, &entry, sizeof(zval *), NULL); - } else { - zend_hash_quick_update(*removed, p->arKey, p->nKeyLength, p->h, &entry, sizeof(zval *), NULL); - } - } - } else { /* otherwise just skip those entries */ - for ( ; pos < offset + length && p; pos++, p = p->pListNext); - } - - /* If there are entries to insert.. */ - if (list != NULL) { - /* ..for each one, create a new zval, copy entry into it and copy it into the output hash */ - for (i = 0; i < list_count; i++) { - entry = *list[i]; - Z_ADDREF_P(entry); - zend_hash_next_index_insert(out_hash, &entry, sizeof(zval *), NULL); - } - } + zend_hash_internal_pointer_reset(ht); - /* Copy the remaining input hash entries to the output hash */ - for ( ; p ; p = p->pListNext) { - entry = *((zval **)p->pData); - Z_ADDREF_P(entry); - if (p->nKeyLength == 0) { - zend_hash_next_index_insert(out_hash, &entry, sizeof(zval *), NULL); - } else { - zend_hash_quick_update(out_hash, p->arKey, p->nKeyLength, p->h, &entry, sizeof(zval *), NULL); - } + if (ht == &EG(symbol_table)) { + zend_reset_all_cv(&EG(symbol_table) TSRMLS_CC); } - - zend_hash_internal_pointer_reset(out_hash); - return out_hash; } /* }}} */ @@@ -2054,19 -1942,17 +1943,17 @@@ PHP_FUNCTION(array_unshift PHP_FUNCTION(array_splice) { zval *array, /* Input array */ - *repl_array = NULL, /* Replacement array */ + **repl_array = NULL, /* Replacement array */ ***repl = NULL; /* Replacement elements */ - HashTable *new_hash = NULL, /* Output array's hash */ - **rem_hash = NULL; /* Removed elements' hash */ - HashTable old_hash; + HashTable *rem_hash = NULL; /* Removed elements' hash */ Bucket *p; /* Bucket used for traversing hash */ - long i, - offset, - length = 0, - repl_num = 0; /* Number of replacement elements */ - int num_in; /* Number of elements in the input array */ + php_int_t i; + php_int_t offset, + length = 0; + php_int_t repl_num = 0; /* Number of replacement elements */ + php_int_t num_in; /* Number of elements in the input array */ - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ai|iz/", &array, &offset, &length, &repl_array) == FAILURE) { - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "al|lZ", &array, &offset, &length, &repl_array) == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ai|iZ", &array, &offset, &length, &repl_array) == FAILURE) { return; } @@@ -2687,12 -2561,10 +2562,10 @@@ PHP_FUNCTION(array_pad zval *input; /* Input array */ zval *pad_value; /* Padding value obviously */ zval ***pads; /* Array to pass to splice */ - HashTable *new_hash;/* Return value from splice */ - HashTable old_hash; - long pad_size; /* Size to pad to */ - long pad_size_abs; /* Absolute value of pad_size */ - int input_size; /* Size of the input array */ - int num_pads; /* How many pads do we need */ + php_int_t pad_size; /* Size to pad to */ + php_int_t pad_size_abs; /* Absolute value of pad_size */ - int input_size; /* Size of the input array */ - php_int_t num_pads; /* How many pads do we need */ ++ php_int_t input_size; /* Size of the input array */ ++ php_int_t num_pads; /* How many pads do we need */ int do_pad; /* Whether we should do padding at all */ int i; diff --cc ext/standard/php_array.h index 4b69d19,deddeb4..2f470c2 --- a/ext/standard/php_array.h +++ b/ext/standard/php_array.h @@@ -103,7 -103,7 +103,7 @@@ PHP_FUNCTION(array_key_exists) PHP_FUNCTION(array_chunk); PHP_FUNCTION(array_combine); - PHPAPI HashTable* php_splice(HashTable *, php_int_t, php_int_t, zval ***, php_int_t, HashTable **); -PHPAPI void php_splice(HashTable *ht, zend_uint offset, zend_uint length, zval ***list, zend_uint list_count, HashTable *removed TSRMLS_DC); ++PHPAPI void php_splice(HashTable *ht, php_uint_t offset, php_size_t length, zval ***list, php_size_t list_count, HashTable *removed TSRMLS_DC); PHPAPI int php_array_merge(HashTable *dest, HashTable *src, int recursive TSRMLS_DC); PHPAPI int php_array_replace_recursive(HashTable *dest, HashTable *src TSRMLS_DC); PHPAPI int php_multisort_compare(const void *a, const void *b TSRMLS_DC);