]> granicus.if.org Git - php/commitdiff
array_pop wasnt setting next index
authorBrad LaFountain <rodif_bl@php.net>
Thu, 1 Aug 2002 17:34:31 +0000 (17:34 +0000)
committerBrad LaFountain <rodif_bl@php.net>
Thu, 1 Aug 2002 17:34:31 +0000 (17:34 +0000)
ext/standard/array.c

index 9d01b233ae9202cee7d0d3618d536e73cbb10098..4f2dbf12c88861418841137ed48f7c90a972dd4c 100644 (file)
@@ -1663,7 +1663,7 @@ static void _phpi_pop(INTERNAL_FUNCTION_PARAMETERS, int off_the_end)
        zval       **stack,                     /* Input stack */
                           **val;                       /* Value to be popped */
        char *key = NULL;
-       int key_len;
+       int key_len = 0;
        ulong index;
        
        /* Get the arguments and do error-checking */
@@ -1696,19 +1696,16 @@ static void _phpi_pop(INTERNAL_FUNCTION_PARAMETERS, int off_the_end)
        
        /* If we did a shift... re-index like it did before */
        if (!off_the_end) {
-               HANDLE_BLOCK_INTERRUPTIONS();
-               {
-                       int k = 0;
-                       Bucket *p = Z_ARRVAL_PP(stack)->pListHead;
-                       while (p != NULL) {
-                               if (p->nKeyLength == 0)
-                                       p->h = k++;
-                               p = p->pListNext;
-                       }
-                       Z_ARRVAL_PP(stack)->nNextFreeElement = k+1;
-                       zend_hash_rehash(Z_ARRVAL_PP(stack));
+               int k = 0;
+               Bucket *p = Z_ARRVAL_PP(stack)->pListHead;
+               while (p != NULL) {
+                       if (p->nKeyLength == 0)
+                               p->h = k++;
+                       p = p->pListNext;
                }
-               HANDLE_UNBLOCK_INTERRUPTIONS();
+               Z_ARRVAL_PP(stack)->nNextFreeElement = k+1;
+       } else if(!key_len) {
+               Z_ARRVAL_PP(stack)->nNextFreeElement = Z_ARRVAL_PP(stack)->nNextFreeElement - 1;
        }
 }
 /* }}} */