]> granicus.if.org Git - php/commitdiff
Heads up people!
authorZeev Suraski <zeev@php.net>
Fri, 22 Dec 2000 12:57:09 +0000 (12:57 +0000)
committerZeev Suraski <zeev@php.net>
Fri, 22 Dec 2000 12:57:09 +0000 (12:57 +0000)
Updated the get_current_key() API - the relevant authors, please take
a look at the updated code and make sure it's ok...

18 files changed:
ext/curl/curl.c
ext/hyperwave/hw.c
ext/imap/php_imap.c
ext/java/java.c
ext/ldap/ldap.c
ext/oracle/oracle.c
ext/pcre/php_pcre.c
ext/pfpro/pfpro.c
ext/rpc/com/COM.c
ext/rpc/java/java.c
ext/sablot/sablot.c
ext/session/session.c
ext/standard/array.c
ext/standard/info.c
ext/standard/string.c
ext/standard/var.c
ext/wddx/wddx.c
sapi/apache2filter/apache_config.c

index a16aef6f0b60f7a42239895889c72dc5ed771418..f367ba9bd984cbfb195c8f516513e77d759c6605 100644 (file)
@@ -433,7 +433,7 @@ PHP_FUNCTION(curl_setopt)
                                        SEPARATE_ZVAL(current);
                                        convert_to_string_ex(current);
                                        
-                                       if (zend_hash_get_current_key(u_post, &string_key, &num_key) == HASH_KEY_IS_LONG) {
+                                       if (zend_hash_get_current_key(u_post, &string_key, &num_key, 0) == HASH_KEY_IS_LONG) {
                                                php_error(E_WARNING, "Array passed to %s() must be an associative array", get_active_function_name());
                                                RETURN_FALSE;
                                        }
@@ -448,8 +448,7 @@ PHP_FUNCTION(curl_setopt)
                                        sprintf(str, "%s=%s", string_key, val_str);
 
                                        ret = curl_formparse(str, &first, &last);
-                                       
-                                       efree(string_key);
+
                                        efree(val_str);
                                }
                                
index c5871c41f2c6ab7dc2bdd5733c5476a826a303bc..c7518f25a12ce4e910b01280a6fb61ac2cd76d68 100644 (file)
@@ -551,7 +551,7 @@ static char * make_objrec_from_array(HashTable *lht) {
        objrec = malloc(1);
        *objrec = '\0';
        for(i=0; i<count; i++) {
-               keytype = zend_hash_get_current_key(lht, &key, &length);
+               keytype = zend_hash_get_current_key(lht, &key, &length, 0);
 /*             if(HASH_KEY_IS_STRING == keytype) { */
                        zend_hash_get_current_data(lht, (void **) &keydataptr);
                        keydata = *keydataptr;
@@ -601,7 +601,6 @@ static char * make_objrec_from_array(HashTable *lht) {
                                        break;
                                }
                        }
-                       if(HASH_KEY_IS_STRING == keytype) efree(key);
                        objrec = realloc(objrec, strlen(objrec)+strlen(str)+1);
                        strcat(objrec, str);
 /*             } */
@@ -1567,7 +1566,7 @@ PHP_FUNCTION(hw_changeobject) {
                int j, noinsert=1;
                ulong ind;
 
-               zend_hash_get_current_key(newobjarr, &key, &ind);
+               zend_hash_get_current_key(newobjarr, &key, &ind, 0);
                zend_hash_get_current_data(newobjarr, (void *) &dataptr);
                data = *dataptr;
                switch(data->type) {
@@ -1599,7 +1598,6 @@ PHP_FUNCTION(hw_changeobject) {
                                modification = fnInsStr(modification, 0, "rem ");
                        } 
                }
-               efree(key);
                zend_hash_move_forward(newobjarr);
        }
        efree(oldobjrec);
@@ -1667,7 +1665,7 @@ PHP_FUNCTION(hw_modifyobject) {
                        int noinsert=1;
                        ulong ind;
 
-                       zend_hash_get_current_key(addobjarr, &key, &ind);
+                       zend_hash_get_current_key(addobjarr, &key, &ind, 0);
                        zend_hash_get_current_data(addobjarr, (void *) &dataptr);
                        data = *dataptr;
                        switch(data->type) {
@@ -1721,7 +1719,6 @@ PHP_FUNCTION(hw_modifyobject) {
                                modification = fnInsStr(modification, 0, "\\");
                                modification = fnInsStr(modification, 0, addattribute);
                        }
-                       efree(key);
                        zend_hash_move_forward(addobjarr);
                }
        }
@@ -1736,7 +1733,7 @@ PHP_FUNCTION(hw_modifyobject) {
                        int noinsert=1;
                        ulong ind;
 
-                       zend_hash_get_current_key(remobjarr, &key, &ind);
+                       zend_hash_get_current_key(remobjarr, &key, &ind, 0);
                        zend_hash_get_current_data(remobjarr, (void *) &dataptr);
                        data = *dataptr;
                        switch(data->type) {
@@ -1793,7 +1790,6 @@ PHP_FUNCTION(hw_modifyobject) {
                                modification = fnInsStr(modification, 0, "\\");
                                modification = fnInsStr(modification, 0, remattribute);
                        }
-                       efree(key);
                        zend_hash_move_forward(remobjarr);
                }
        }
@@ -2349,7 +2345,7 @@ PHP_FUNCTION(hw_pipedocument) {
                        zval *data, **dataptr;
                        ulong ind;
                        
-                       zend_hash_get_current_key(prefixarray, &key, &ind);
+                       zend_hash_get_current_key(prefixarray, &key, &ind, 0);
                        zend_hash_get_current_data(prefixarray, (void *) &dataptr);
                        data = *dataptr;
                        if (data->type != IS_STRING) {
@@ -2369,7 +2365,6 @@ PHP_FUNCTION(hw_pipedocument) {
                                php_error(E_WARNING,"%s is not a valid urlprefix", key);
                                RETURN_FALSE;
                        }
-                       efree(key);
                        zend_hash_move_forward(prefixarray);
                }
        } else {
@@ -4151,7 +4146,7 @@ PHP_FUNCTION(hw_insertanchors) {
                        zval *data, **dataptr;
                        ulong ind;
                        
-                       zend_hash_get_current_key(prefixarray, &key, &ind);
+                       zend_hash_get_current_key(prefixarray, &key, &ind, 0);
                        zend_hash_get_current_data(prefixarray, (void *) &dataptr);
                        data = *dataptr;
                        if (data->type != IS_STRING) {
@@ -4171,7 +4166,6 @@ PHP_FUNCTION(hw_insertanchors) {
                                php_error(E_WARNING,"%s is not a valid urlprefix", key);
                                RETURN_FALSE;
                        }
-                       efree(key);
                        zend_hash_move_forward(prefixarray);
                }
        } else {
index 520aa712b3922e0a052a585c59a9c00d0065bfdd..ca4b274a0384d6d936de5548b9582955bca3a1a7 100644 (file)
@@ -3109,7 +3109,7 @@ PHP_FUNCTION(imap_mail_compose)
 
        zend_hash_internal_pointer_reset(Z_ARRVAL_PP(body));
        zend_hash_get_current_data(Z_ARRVAL_PP(body), (void **) &data);
-       zend_hash_get_current_key(Z_ARRVAL_PP(body), &key, &ind);
+       zend_hash_get_current_key(Z_ARRVAL_PP(body), &key, &ind, 0); /* FIXME: is this necessary?  we're not using key/ind */
 
        if (Z_TYPE_PP(data) == IS_ARRAY) {
                bod=mail_newbody();
@@ -3154,7 +3154,7 @@ PHP_FUNCTION(imap_mail_compose)
        zend_hash_move_forward(Z_ARRVAL_PP(body));
 
        while(zend_hash_get_current_data(Z_ARRVAL_PP(body), (void **) &data) == SUCCESS) { 
-               zend_hash_get_current_key(Z_ARRVAL_PP(body), &key, &ind); 
+               zend_hash_get_current_key(Z_ARRVAL_PP(body), &key, &ind, 0);  /* FIXME: Is this necessary?  We're not using key/ind */
                if (Z_TYPE_PP(data) == IS_ARRAY) {
                        if (!toppart) {
                                bod->nested.part=mail_newbody_part();
index acf699a396b6e8f263349dd1fcbd03019d2d0d58..68541f673e0e20019b57df234dce0f742f20da32 100644 (file)
@@ -349,13 +349,12 @@ static jobject _java_makeObject(pval* arg JG_DC) {
       while(zend_hash_get_current_data(arg->value.ht, (void**)&value) == SUCCESS) {
         jval = _java_makeObject(*value JG_CC);
 
-        switch (zend_hash_get_current_key(arg->value.ht, &string_key, &num_key)) {
+        switch (zend_hash_get_current_key(arg->value.ht, &string_key, &num_key, 0)) {
           case HASH_KEY_IS_STRING:
             key.type = IS_STRING;
             key.value.str.val = string_key;
             key.value.str.len = strlen(string_key);
             jkey = _java_makeObject(&key JG_CC);
-            efree(string_key);
             break;
           case HASH_KEY_IS_LONG:
             key.type = IS_LONG;
index 914def184a6c2b8f4333ddef8084d6cde0f5d2a5..41b89fb1aeaec9636eea541c99c48b680509c360 100644 (file)
@@ -1264,9 +1264,8 @@ static void php_ldap_do_modify(INTERNAL_FUNCTION_PARAMETERS, int oper)
                ldap_mods[i] = emalloc(sizeof(LDAPMod));
                ldap_mods[i]->mod_op = oper | LDAP_MOD_BVALUES;
 
-               if (zend_hash_get_current_key((*entry)->value.ht,&attribute, &index) == HASH_KEY_IS_STRING) {
+               if (zend_hash_get_current_key((*entry)->value.ht, &attribute, &index, 0) == HASH_KEY_IS_STRING) {
                        ldap_mods[i]->mod_type = estrdup(attribute);
-                       efree(attribute);
                } else {
                        php_error(E_ERROR, "LDAP: Unknown Attribute in the data");
                        RETURN_FALSE;
index a36071b3c65c775b805393b9b5c564645594d10e..c69ac6339965a878659761ed5d432423f51d9a2b 100644 (file)
@@ -1691,20 +1691,18 @@ int ora_set_param_values(oraCursor *cursor, int isout)
        }
 
        for(i = 0; i < cursor->nparams; i++, zend_hash_move_forward(cursor->params)){
-               if(zend_hash_get_current_key(cursor->params, &paramname, NULL) != HASH_KEY_IS_STRING){
+               if(zend_hash_get_current_key(cursor->params, &paramname, NULL, 0) != HASH_KEY_IS_STRING){
                        php_error(E_WARNING, "Can't get parameter name");
                        return 0;
                }
 
                if(zend_hash_get_current_data(cursor->params, (void **)&param) == FAILURE){
                        php_error(E_WARNING, "Can't get parameter data");
-                       efree(paramname);
                        return 0;
                }
 
                if(isout){
                        SET_VAR_STRINGL(paramname, estrdup(param->progv), strlen(param->progv));
-                       efree(paramname);
                        continue;
                }
                
index 9c39bf8324e064d11a7df3451c5e76b70350d46d..e4480d468ce2c2cf0f2c7ee87cbe66108de8d0e7 100644 (file)
@@ -1017,11 +1017,10 @@ PHP_FUNCTION(preg_replace)
                                                                                  (void **)&subject_entry) == SUCCESS) {
                        if ((result = php_replace_in_subject(*regex, *replace, subject_entry, &result_len, limit_val)) != NULL) {
                                /* Add to return array */
-                               switch(zend_hash_get_current_key((*subject)->value.ht, &string_key, &num_key))
+                               switch(zend_hash_get_current_key((*subject)->value.ht, &string_key, &num_key, 0))
                                {
                                        case HASH_KEY_IS_STRING:
                                                add_assoc_stringl(return_value, string_key, result, result_len, 0);
-                                               efree(string_key);
                                                break;
 
                                        case HASH_KEY_IS_LONG:
@@ -1314,12 +1313,11 @@ PHP_FUNCTION(preg_grep)
                        (*entry)->refcount++;
 
                        /* Add to return array */
-                       switch(zend_hash_get_current_key((*input)->value.ht, &string_key, &num_key))
+                       switch(zend_hash_get_current_key((*input)->value.ht, &string_key, &num_key, 0))
                        {
                                case HASH_KEY_IS_STRING:
                                        zend_hash_update(return_value->value.ht, string_key,
                                                                         strlen(string_key)+1, entry, sizeof(zval *), NULL);
-                                       efree(string_key);
                                        break;
 
                                case HASH_KEY_IS_LONG:
index e68e24097b4dc6c319ee9407939cbdddd7f70c9d..491e000baa4ff15b63dd41e197202e0dc3412b19 100644 (file)
@@ -409,7 +409,7 @@ PHP_FUNCTION(pfpro_process)
                                parmlength += 1;
                        }
 
-                       switch (zend_hash_get_current_key(target_hash, &string_key, &num_key)) {
+                       switch (zend_hash_get_current_key(target_hash, &string_key, &num_key, 0)) {
 
                                case HASH_KEY_IS_STRING:
 
@@ -417,8 +417,6 @@ PHP_FUNCTION(pfpro_process)
                                                strcpy(parmlist + parmlength, string_key);
                                        parmlength += strlen(string_key);
 
-                                       efree(string_key);
-
                                        break;
 
                                case HASH_KEY_IS_LONG:
index 1ff3f006b589f9bec2afa5f6a660af99bbeb2626..7f6a606eceacfe99c6a2938bfc16c15ab81a8e1e 100644 (file)
@@ -367,6 +367,20 @@ static void php_variant_to_pval(VARIANTARG *var_arg, pval *pval_arg, int persist
                        }
                        pval_arg->type = IS_DOUBLE;
                        break;
+               case VT_DECIMAL:
+                       switch (VarR8FromDec(&var_arg->decVal, &pval_arg->value.dval)) {
+                               case DISP_E_OVERFLOW:
+                                       php_error(E_WARNING, "Overflow converting DECIMAL value to PHP floating point - number truncated");
+                                       pval_arg->value.dval = DBL_MAX;
+                                       /* break missing intentionally */
+                               case S_OK:
+                                       pval_arg->type = IS_DOUBLE;
+                                       break;
+                               default:
+                                       php_error(E_WARNING, "Error converting DECIMAL value to PHP floating point");
+                                       break;
+                       }
+                       break;
                case VT_BOOL:
                        if (pval_arg->is_ref == 0 || (var_arg->vt & VT_BYREF) != VT_BYREF) {
                                if (var_arg->boolVal & 0xFFFF) {
@@ -383,6 +397,9 @@ static void php_variant_to_pval(VARIANTARG *var_arg, pval *pval_arg, int persist
                        }
                        pval_arg->type = IS_BOOL;
                        break;
+               case VT_VOID:
+                       pval_arg->type = IS_NULL;
+                       break;
                case VT_BSTR:
                        if (pval_arg->is_ref == 0  || (var_arg->vt & VT_BYREF) != VT_BYREF) {
                                pval_arg->value.str.val = php_OLECHAR_to_char(var_arg->bstrVal, &pval_arg->value.str.len, persistent);
@@ -432,7 +449,7 @@ static void php_variant_to_pval(VARIANTARG *var_arg, pval *pval_arg, int persist
                        break;
                case VT_UNKNOWN:
                        var_arg->pdispVal->lpVtbl->Release(var_arg->pdispVal);
-                       /* fallthru */
+                       /* break missing intentionally */
                default:
                        php_error(E_WARNING,"Unsupported variant type: %d (0x%X)", var_arg->vt, var_arg->vt);
                        var_reset(pval_arg);
index acf699a396b6e8f263349dd1fcbd03019d2d0d58..68541f673e0e20019b57df234dce0f742f20da32 100644 (file)
@@ -349,13 +349,12 @@ static jobject _java_makeObject(pval* arg JG_DC) {
       while(zend_hash_get_current_data(arg->value.ht, (void**)&value) == SUCCESS) {
         jval = _java_makeObject(*value JG_CC);
 
-        switch (zend_hash_get_current_key(arg->value.ht, &string_key, &num_key)) {
+        switch (zend_hash_get_current_key(arg->value.ht, &string_key, &num_key, 0)) {
           case HASH_KEY_IS_STRING:
             key.type = IS_STRING;
             key.value.str.val = string_key;
             key.value.str.len = strlen(string_key);
             jkey = _java_makeObject(&key JG_CC);
-            efree(string_key);
             break;
           case HASH_KEY_IS_LONG:
             key.type = IS_LONG;
index 78c6f9b56c4edb82be99b907e9984e0d4159b1e3..e0f1c6ae280eb32c33056ff08ebac409f8032901 100644 (file)
@@ -801,7 +801,7 @@ PHP_FUNCTION(xslt_set_sax_handler)
         
         SEPARATE_ZVAL(indiv_handlers);
         
-        if (zend_hash_get_current_key(handlers_list, &string_key, &num_key) == HASH_KEY_IS_LONG) {
+        if (zend_hash_get_current_key(handlers_list, &string_key, &num_key, 0) == HASH_KEY_IS_LONG) {
             php_error(E_WARNING, "The Keys of the first dimension of your array must be strings");
             RETURN_FALSE;
         }
@@ -830,9 +830,7 @@ PHP_FUNCTION(xslt_set_sax_handler)
         } else {        
             php_error(E_WARNING, "Invalid option: %s", string_key);
         }
-        
-        S_FREE(string_key);
-    }
+       }
 }
 /* }}} */
 
@@ -1394,7 +1392,7 @@ static void _php_sablot_ht_char(HashTable *php, char **sablot)
         SEPARATE_ZVAL(value);
         convert_to_string_ex(value);
         
-        switch (zend_hash_get_current_key(php, &string_key, &num_key)) {
+        switch (zend_hash_get_current_key(php, &string_key, &num_key, 1)) {
             case HASH_KEY_IS_LONG:
                 sablot[i++] = Z_STRVAL_PP(value);
                 break;
index 7178caa35dd67887555b1a2319b2a252be77c77d..211d234479b94415df4dcceefabd65b5e76ae70c 100644 (file)
@@ -199,12 +199,11 @@ typedef struct {
 
 #define ENCODE_LOOP(code)                                                                              \
        for (zend_hash_internal_pointer_reset(&PS(vars));                       \
-                       zend_hash_get_current_key(&PS(vars), &key, &num_key) == HASH_KEY_IS_STRING; \
+                       zend_hash_get_current_key(&PS(vars), &key, &num_key, 0) == HASH_KEY_IS_STRING; \
                        zend_hash_move_forward(&PS(vars))) {                            \
                if (php_get_session_var(key, strlen(key), &struc PLS_CC PSLS_CC ELS_CC) == SUCCESS) { \
                        code;                                                                                           \
                }                                                                                                               \
-               efree(key);                                                                                             \
        }
 
 static void php_set_session_var(char *name, size_t namelen,
@@ -452,7 +451,6 @@ PS_SERIALIZER_DECODE_FUNC(wddx)
        char tmp[128];
        ulong idx;
        int hash_type;
-       int dofree = 1;
        int ret;
 
        if (vallen == 0) 
@@ -465,19 +463,16 @@ PS_SERIALIZER_DECODE_FUNC(wddx)
                for (zend_hash_internal_pointer_reset(Z_ARRVAL_P(retval));
                         zend_hash_get_current_data(Z_ARRVAL_P(retval), (void **) &ent) == SUCCESS;
                         zend_hash_move_forward(Z_ARRVAL_P(retval))) {
-                       hash_type = zend_hash_get_current_key(Z_ARRVAL_P(retval), &key, &idx);
+                       hash_type = zend_hash_get_current_key(Z_ARRVAL_P(retval), &key, &idx, 0);
 
                        switch (hash_type) {
                                case HASH_KEY_IS_LONG:
                                        sprintf(tmp, "%ld", idx);
                                        key = tmp;
-                                       dofree = 0;
                                        /* fallthru */
                                case HASH_KEY_IS_STRING:
                                        php_set_session_var(key, strlen(key), *ent PSLS_CC);
                                        PS_ADD_VAR(key);
-                                       if (dofree) efree(key);
-                                       dofree = 1;
                        }
                }
        }
@@ -601,7 +596,7 @@ static void php_session_save_current_state(PSLS_D)
                }
 
                for (zend_hash_internal_pointer_reset(Z_ARRVAL_P(PS(http_session_vars)));
-                               zend_hash_get_current_key(Z_ARRVAL_P(PS(http_session_vars)), &variable, &num_key) == HASH_KEY_IS_STRING;
+                               zend_hash_get_current_key(Z_ARRVAL_P(PS(http_session_vars)), &variable, &num_key, 1) == HASH_KEY_IS_STRING;
                                zend_hash_move_forward(Z_ARRVAL_P(PS(http_session_vars)))) {
                        PS_ADD_VAR(variable);
                }
@@ -1394,12 +1389,11 @@ PHP_FUNCTION(session_unset)
        PSLS_FETCH();
        
        for (zend_hash_internal_pointer_reset(&PS(vars));
-                       zend_hash_get_current_key(&PS(vars), &variable, &num_key) == HASH_KEY_IS_STRING;
+                       zend_hash_get_current_key(&PS(vars), &variable, &num_key, 0) == HASH_KEY_IS_STRING;
                        zend_hash_move_forward(&PS(vars))) {
                if (zend_hash_find(&EG(symbol_table), variable, strlen(variable) + 1, (void **) &tmp)
                                == SUCCESS)
                        zend_hash_del(&EG(symbol_table), variable, strlen(variable) + 1);
-               efree(variable);
        }
 
        /* Clean $HTTP_SESSION_VARS. */
index ef7656bd34fa1c5229bdca75787724561ebb1305..f1eca09fa389aae2b3085be98ce4e255b68108e4 100644 (file)
@@ -876,7 +876,7 @@ PHP_FUNCTION(key)
                php_error(E_WARNING, "Variable passed to key() is not an array or object");
                RETURN_FALSE;
        }
-       switch (zend_hash_get_current_key(target_hash, &string_key, &num_key)) {
+       switch (zend_hash_get_current_key(target_hash, &string_key, &num_key, 1)) {
                case HASH_KEY_IS_STRING:
                        RETVAL_STRING(string_key, 0);
                        break;
@@ -1015,7 +1015,7 @@ static int php_array_walk(HashTable *target_hash, zval **userdata)
        /* Iterate through hash */
        while(zend_hash_get_current_data(target_hash, (void **)&args[0]) == SUCCESS) {
                /* Set up the key */
-               if (zend_hash_get_current_key(target_hash, &string_key, &num_key) == HASH_KEY_IS_LONG) {
+               if (zend_hash_get_current_key(target_hash, &string_key, &num_key, 1) == HASH_KEY_IS_LONG) {
                        Z_TYPE_P(key) = IS_LONG;
                        Z_LVAL_P(key) = num_key;
                } else {
@@ -1213,7 +1213,7 @@ PHP_FUNCTION(extract)
        zend_hash_internal_pointer_reset(Z_ARRVAL_PP(var_array));
        while(zend_hash_get_current_data(Z_ARRVAL_PP(var_array), (void **)&entry) == SUCCESS) {
 
-               if (zend_hash_get_current_key(Z_ARRVAL_PP(var_array), &varname, &lkey) == HASH_KEY_IS_STRING) {
+               if (zend_hash_get_current_key(Z_ARRVAL_PP(var_array), &varname, &lkey, 0) == HASH_KEY_IS_STRING) {
 
                        if (_valid_var_name(varname)) {
                                finalname = NULL;
@@ -1253,8 +1253,6 @@ PHP_FUNCTION(extract)
                                        efree(finalname);
                                }
                        }
-
-                       efree(varname);
                }
 
                zend_hash_move_forward(Z_ARRVAL_PP(var_array));
@@ -1777,11 +1775,10 @@ PHP_FUNCTION(array_slice)
                
                (*entry)->refcount++;
 
-               switch (zend_hash_get_current_key(Z_ARRVAL_PP(input), &string_key, &num_key)) {
+               switch (zend_hash_get_current_key(Z_ARRVAL_PP(input), &string_key, &num_key, 0)) {
                        case HASH_KEY_IS_STRING:
                                zend_hash_update(Z_ARRVAL_P(return_value), string_key, strlen(string_key)+1,
                                                                 entry, sizeof(zval *), NULL);
-                               efree(string_key);
                                break;
        
                        case HASH_KEY_IS_LONG:
@@ -1805,7 +1802,7 @@ PHPAPI void php_array_merge(HashTable *dest, HashTable *src, int recursive)
 
        zend_hash_internal_pointer_reset(src);
        while(zend_hash_get_current_data(src, (void **)&src_entry) == SUCCESS) {
-               switch (zend_hash_get_current_key(src, &string_key, &num_key)) {
+               switch (zend_hash_get_current_key(src, &string_key, &num_key, 0)) {
                        case HASH_KEY_IS_STRING:
                                if (recursive &&
                                        zend_hash_find(dest, string_key, strlen(string_key) + 1,
@@ -1820,7 +1817,6 @@ PHPAPI void php_array_merge(HashTable *dest, HashTable *src, int recursive)
                                        zend_hash_update(dest, string_key, strlen(string_key)+1,
                                                                         src_entry, sizeof(zval *), NULL);
                                }
-                               efree(string_key);
                                break;
 
                        case HASH_KEY_IS_LONG:
@@ -1922,7 +1918,7 @@ PHP_FUNCTION(array_keys)
                if (add_key) {  
                        MAKE_STD_ZVAL(new_val);
 
-                       switch (zend_hash_get_current_key(Z_ARRVAL_PP(input), &string_key, &num_key)) {
+                       switch (zend_hash_get_current_key(Z_ARRVAL_PP(input), &string_key, &num_key, 1)) {
                                case HASH_KEY_IS_STRING:
                                        Z_TYPE_P(new_val) = IS_STRING;
                                        Z_STRVAL_P(new_val) = string_key;
@@ -2075,11 +2071,10 @@ PHP_FUNCTION(array_reverse)
        while(zend_hash_get_current_data(Z_ARRVAL_PP(input), (void **)&entry) == SUCCESS) {
                (*entry)->refcount++;
                
-               switch (zend_hash_get_current_key(Z_ARRVAL_PP(input), &string_key, &num_key)) {
+               switch (zend_hash_get_current_key(Z_ARRVAL_PP(input), &string_key, &num_key, 0)) {
                        case HASH_KEY_IS_STRING:
                                zend_hash_update(Z_ARRVAL_P(return_value), string_key, strlen(string_key)+1,
                                                                 entry, sizeof(zval *), NULL);
-                               efree(string_key);
                                break;
 
                        case HASH_KEY_IS_LONG:
@@ -2186,7 +2181,7 @@ PHP_FUNCTION(array_flip)
        zend_hash_internal_pointer_reset(target_hash);
        while (zend_hash_get_current_data(target_hash, (void **)&entry) == SUCCESS) {
                MAKE_STD_ZVAL(data);
-               switch (zend_hash_get_current_key(target_hash, &string_key, &num_key)) {
+               switch (zend_hash_get_current_key(target_hash, &string_key, &num_key, 1)) {
                        case HASH_KEY_IS_STRING:
                                Z_STRVAL_P(data) = string_key;
                                Z_STRLEN_P(data) = strlen(string_key);
@@ -2726,7 +2721,7 @@ PHP_FUNCTION(array_rand)
 
        /* We can't use zend_hash_index_find() because the array may have string keys or gaps. */
        zend_hash_internal_pointer_reset(Z_ARRVAL_PP(input));
-       while (num_req_val && (key_type = zend_hash_get_current_key(Z_ARRVAL_PP(input), &string_key, &num_key)) != HASH_KEY_NON_EXISTANT) {
+       while (num_req_val && (key_type = zend_hash_get_current_key(Z_ARRVAL_PP(input), &string_key, &num_key, 0)) != HASH_KEY_NON_EXISTANT) {
 
 #ifdef HAVE_LRAND48
                randval = lrand48();
@@ -2742,21 +2737,19 @@ PHP_FUNCTION(array_rand)
                        /* If we are returning a single result, just do it. */
                        if (Z_TYPE_P(return_value) != IS_ARRAY) {
                                if (key_type == HASH_KEY_IS_STRING) {
-                                       RETURN_STRING(string_key, 0);
+                                       RETURN_STRING(string_key, 1);
                                } else {
                                        RETURN_LONG(num_key);
                                }
                        } else {
                                /* Append the result to the return value. */
                                if (key_type == HASH_KEY_IS_STRING)
-                                       add_next_index_string(return_value, string_key, 0);
+                                       add_next_index_string(return_value, string_key, 1);
                                else
                                        add_next_index_long(return_value, num_key);
                        }
                        num_req_val--;
-               } else if (key_type == HASH_KEY_IS_STRING)
-                       efree(string_key);
-
+               }
                num_avail--;
                zend_hash_move_forward(Z_ARRVAL_PP(input));
        }  
index 17dedeea3cc221fdf851b6540aa317037d56c17e..ecd3ab0a10a8bbd44063e9426a5682d47f7dfe88 100644 (file)
@@ -82,10 +82,9 @@ static void php_print_gpcse_array(char *name, uint name_length ELS_DC)
                        PUTS("<TD BGCOLOR=\"" PHP_ENTRY_NAME_COLOR "\"><B>");
                        PUTS(name);
                        PUTS("[\"");
-                       switch (zend_hash_get_current_key((*data)->value.ht, &string_key, &num_key)) {
+                       switch (zend_hash_get_current_key((*data)->value.ht, &string_key, &num_key, 0)) {
                                case HASH_KEY_IS_STRING:
                                        PUTS(string_key);
-                                       efree(string_key);
                                        break;
                                case HASH_KEY_IS_LONG:
                                        php_printf("%ld",num_key);
index 486a14d6bbbc8349fe540092cb96940217db83e1..c07e564ada0152c93f5309681f5298af7eba7edf 100644 (file)
@@ -1488,12 +1488,11 @@ static void php_strtr_array(zval *return_value,char *str,int slen,HashTable *has
        
        zend_hash_internal_pointer_reset_ex(hash, &hpos);
        while (zend_hash_get_current_data_ex(hash, (void **)&entry, &hpos) == SUCCESS) {
-               switch (zend_hash_get_current_key_ex(hash, &string_key, NULL, &num_key, &hpos)) {
+               switch (zend_hash_get_current_key_ex(hash, &string_key, NULL, &num_key, 0, &hpos)) {
                case HASH_KEY_IS_STRING:
                        len = strlen(string_key);
                        if (len > maxlen) maxlen = len;
                        if (len < minlen) minlen = len;
-                       efree(string_key);
                        break; 
                        
                case HASH_KEY_IS_LONG:
index 0eb531eefb706dfb6dce184b9b41d4085d9b3cef..221ce20c27d16664543bccc93c00a6550047e0f0 100644 (file)
@@ -259,7 +259,7 @@ void php_var_serialize(pval *buf, pval **struc, HashTable *var_hash)
                                                        
                                                        zend_hash_internal_pointer_reset_ex(HASH_OF(retval_ptr),&pos);
                                                        for (;; zend_hash_move_forward_ex(HASH_OF(retval_ptr),&pos)) {
-                                                               if ((i = zend_hash_get_current_key_ex(HASH_OF(retval_ptr), &key, NULL, &index, &pos)) == HASH_KEY_NON_EXISTANT) {
+                                                               if ((i = zend_hash_get_current_key_ex(HASH_OF(retval_ptr), &key, NULL, &index, 0, &pos)) == HASH_KEY_NON_EXISTANT) {
                                                                        break;
                                                                }
 
@@ -319,12 +319,10 @@ void php_var_serialize(pval *buf, pval **struc, HashTable *var_hash)
                                
                                zend_hash_internal_pointer_reset_ex(myht, &pos);
                                for (;; zend_hash_move_forward_ex(myht, &pos)) {
-                                       if ((i = zend_hash_get_current_key_ex(myht, &key, NULL, &index, &pos)) == HASH_KEY_NON_EXISTANT) {
+                                       if ((i = zend_hash_get_current_key_ex(myht, &key, NULL, &index, 0, &pos)) == HASH_KEY_NON_EXISTANT) {
                                                break;
                                        }
                                        if (zend_hash_get_current_data_ex(myht, (void **) (&data), &pos) != SUCCESS || !data /* || ((*data) == (*struc)) */) {
-                                               if (i == HASH_KEY_IS_STRING)
-                                                       efree(key);
                                                continue;
                                        }
 
index ed838504a60933d67c8ebb5f6f91937670caecb5..22dbfc1c35bfa8a036802406eb0dd0b60b6a7973 100644 (file)
@@ -476,9 +476,8 @@ static void php_wddx_serialize_object(wddx_packet *packet, zval *obj)
                        if (*ent == obj)
                                continue;
 
-                       if (zend_hash_get_current_key(HASH_OF(obj), &key, &idx) == HASH_KEY_IS_STRING) {
+                       if (zend_hash_get_current_key(HASH_OF(obj), &key, &idx, 0) == HASH_KEY_IS_STRING) {
                                php_wddx_serialize_var(packet, *ent, key);
-                               efree(key);
                        } else {
                                sprintf(tmp_buf, "%ld", idx);
                                php_wddx_serialize_var(packet, *ent, tmp_buf);
@@ -511,11 +510,10 @@ static void php_wddx_serialize_array(wddx_packet *packet, zval *arr)
                 zend_hash_get_current_data(target_hash, (void**)&ent) == SUCCESS;
                 zend_hash_move_forward(target_hash)) {
 
-               type = zend_hash_get_current_key(target_hash, &key, &idx);
+               type = zend_hash_get_current_key(target_hash, &key, &idx, 0);
 
                if (type == HASH_KEY_IS_STRING) {
                        is_struct = 1;
-                       efree(key);
                        break;
                }
 
@@ -541,11 +539,10 @@ static void php_wddx_serialize_array(wddx_packet *packet, zval *arr)
                        continue;
 
                if (is_struct) {
-                       ent_type = zend_hash_get_current_key(target_hash, &key, &idx);
+                       ent_type = zend_hash_get_current_key(target_hash, &key, &idx, 0);
 
                        if (ent_type == HASH_KEY_IS_STRING) {
                                php_wddx_serialize_var(packet, *ent, key);
-                               efree(key);
                        } else {
                                sprintf(tmp_buf, "%ld", idx);
                                php_wddx_serialize_var(packet, *ent, tmp_buf);
index c15c2e2931c130ba22c16f6c106b5616f0c99035..bf32040cd6301462c9485842273892d96aa84c15 100644 (file)
@@ -87,7 +87,7 @@ void *merge_php_config(apr_pool_t *p, void *base_conf, void *new_conf)
 
        fprintf(stderr, "Merge dir (%p) (%p)\n", base_conf, new_conf);
        for (zend_hash_internal_pointer_reset(&d->config);
-                       zend_hash_get_current_key_ex(&d->config, &str, &str_len, &num_index, NULL) == HASH_KEY_IS_STRING;
+                       zend_hash_get_current_key_ex(&d->config, &str, &str_len, &num_index, 0, NULL) == HASH_KEY_IS_STRING;
                        zend_hash_move_forward(&d->config)) {
                pe = NULL;
                zend_hash_get_current_data(&d->config, (void **) &data);
@@ -108,7 +108,7 @@ void apply_config(void *dummy)
        php_dir_entry *data;
        
        for (zend_hash_internal_pointer_reset(&d->config);
-                       zend_hash_get_current_key_ex(&d->config, &str, &str_len, NULL, NULL) == HASH_KEY_IS_STRING;
+                       zend_hash_get_current_key_ex(&d->config, &str, &str_len, NULL, 0, NULL) == HASH_KEY_IS_STRING;
                        zend_hash_move_forward(&d->config)) {
                zend_hash_get_current_data(&d->config, (void **) &data);
                fprintf(stderr, "APPLYING (%s)(%s)\n", str, data->value);