summaryrefslogtreecommitdiff
path: root/ext/spl/php_spl.c
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2014-07-29 16:23:56 +0400
committerDmitry Stogov <dmitry@zend.com>2014-07-29 16:23:56 +0400
commit46fcd3fc08de938293a8a4fe25f9d1ed18457f4a (patch)
treea0ee8c32b298b21ec2a194cd60ccf2ab486d2b68 /ext/spl/php_spl.c
parent507e3b91930835b698a29bfa7ba978470d6302ef (diff)
downloadphp-git-46fcd3fc08de938293a8a4fe25f9d1ed18457f4a.tar.gz
Fixed callback registraion order in spl_autoload_register()
Diffstat (limited to 'ext/spl/php_spl.c')
-rw-r--r--ext/spl/php_spl.c23
1 files changed, 5 insertions, 18 deletions
diff --git a/ext/spl/php_spl.c b/ext/spl/php_spl.c
index d765d6b754..62cf6ae144 100644
--- a/ext/spl/php_spl.c
+++ b/ext/spl/php_spl.c
@@ -441,24 +441,11 @@ PHP_FUNCTION(spl_autoload_call)
#define HT_MOVE_TAIL_TO_HEAD(ht) \
do { \
- uint first = 0; \
- uint last = (ht)->nNumUsed; \
- while (first < last) { \
- if (Z_TYPE((ht)->arData[first].val) != IS_UNDEF) \
- break; \
- first++; \
- } \
- while (last > first) { \
- last--; \
- if (Z_TYPE((ht)->arData[last].val) != IS_UNDEF) \
- break; \
- } \
- if (first != last) { \
- Bucket tmp = (ht)->arData[first]; \
- (ht)->arData[first] = (ht)->arData[last]; \
- (ht)->arData[last] = tmp; \
- zend_hash_rehash(ht); \
- } \
+ Bucket tmp = (ht)->arData[(ht)->nNumUsed-1]; \
+ memmove((ht)->arData + 1, (ht)->arData, \
+ sizeof(Bucket) * ((ht)->nNumUsed - 1)); \
+ (ht)->arData[0] = tmp; \
+ zend_hash_rehash(ht); \
} while (0)
/* {{{ proto bool spl_autoload_register([mixed autoload_function = "spl_autoload" [, throw = true [, prepend]]])