]> granicus.if.org Git - php/commitdiff
fix array_unique() to return array with any type of argument
authorAntony Dovgal <tony2001@php.net>
Mon, 22 Jan 2007 08:23:08 +0000 (08:23 +0000)
committerAntony Dovgal <tony2001@php.net>
Mon, 22 Jan 2007 08:23:08 +0000 (08:23 +0000)
ext/standard/array.c

index 7100d727b519a7ce94c90572baa7008b7f7211e1..9a8ab5f30d060a6ca457cccd9da19e81c7f899ab 100644 (file)
@@ -2515,7 +2515,7 @@ PHP_FUNCTION(array_change_key_case)
    Removes duplicate values from array */
 PHP_FUNCTION(array_unique)
 {
-       zval **array;
+       zval **array, *tmp;
        HashTable *target_hash;
        Bucket *p;
        struct bucketindex {
@@ -2534,9 +2534,8 @@ PHP_FUNCTION(array_unique)
                RETURN_FALSE;
        }
 
-       /* copy the argument array */
-       *return_value = **array;
-       zval_copy_ctor(return_value);
+       array_init(return_value);
+       zend_hash_copy(Z_ARRVAL_P(return_value), target_hash, (copy_ctor_func_t) zval_add_ref, (void *)&tmp, sizeof(zval*));
 
        if (target_hash->nNumOfElements <= 1) /* nothing to do */
                        return;