From: Zeev Suraski Date: Fri, 9 Jul 1999 20:45:55 +0000 (+0000) Subject: Don't touch refcount and EA directly X-Git-Tag: BEFORE_REMOVING_AI_COUNT_FINAL_STEP~5 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c43c235427418d610f749b97d4a1228b0191a7ed;p=php Don't touch refcount and EA directly --- diff --git a/ext/oci8/oci8.c b/ext/oci8/oci8.c index d2549ffaad..e8685e908f 100644 --- a/ext/oci8/oci8.c +++ b/ext/oci8/oci8.c @@ -3166,15 +3166,13 @@ PHP_FUNCTION(oci8_fetchinto) #if PHP_API_VERSION >= 19990421 element = emalloc(sizeof(pval)); - element->EA=0; - element->refcount=1; + INIT_PZVAL(element); #endif if ((mode & OCI_NUM) || (! (mode & OCI_ASSOC))) { /* OCI_NUM is default */ oci8_make_pval(element,statement,column, "OCIFetchInto",mode); #if PHP_API_VERSION >= 19990421 - element->EA = 0; - element->refcount = 1; + INIT_PZVAL(element); _php3_hash_index_update(array->value.ht, i, (void *)&element, sizeof(pval*), NULL); #else _php3_hash_index_update(array->value.ht, i, (void *)element, sizeof(pval), NULL); @@ -3257,15 +3255,13 @@ PHP_FUNCTION(oci8_fetchstatement) #if PHP_API_VERSION >= 19990421 tmp = emalloc(sizeof(pval)); - tmp->EA = 0; - tmp->refcount = 1; + INIT_PZVAL(tmp); #endif array_init(tmp); #if PHP_API_VERSION >= 19990421 - tmp->EA = 0; - tmp->refcount = 1; + INIT_PZVAL(tmp); #endif memcpy(namebuf,columns[ i ]->name, columns[ i ]->name_len); @@ -3297,8 +3293,7 @@ PHP_FUNCTION(oci8_fetchstatement) #if PHP_API_VERSION < 19990421 _php3_hash_index_update(outarrs[ i ]->value.ht, rows, (void *)element, sizeof(pval), NULL); #else - element->refcount = 1; - element->EA = 0; + INIT_PZVAL(element); _php3_hash_index_update((*(outarrs[ i ]))->value.ht, rows, (void *)&element, sizeof(pval*), NULL); #endif } diff --git a/ext/oracle/oracle.c b/ext/oracle/oracle.c index 2b0a22ae7f..ace254cb57 100644 --- a/ext/oracle/oracle.c +++ b/ext/oracle/oracle.c @@ -1225,8 +1225,7 @@ void php3_Ora_FetchInto(INTERNAL_FUNCTION_PARAMETERS) } else { #if PHP_API_VERSION >= 19990421 tmp = emalloc(sizeof(pval)); - tmp->EA = 0; - tmp->refcount = 1; + INIT_PZVAL(tmp); #endif tmp->type = IS_STRING; diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c index 2e80d02f65..c11739525d 100644 --- a/ext/pcre/php_pcre.c +++ b/ext/pcre/php_pcre.c @@ -394,8 +394,7 @@ static void _pcre_match(INTERNAL_FUNCTION_PARAMETERS, int global) for (i=0; iEA = 0; - match_sets[i]->refcount = 1; + INIT_PZVAL(match_sets[i]); } } @@ -444,8 +443,7 @@ static void _pcre_match(INTERNAL_FUNCTION_PARAMETERS, int global) /* Allocate the result set array */ result_set = emalloc(sizeof(zval)); array_init(result_set); - result_set->EA = 0; - result_set->refcount = 1; + INIT_PZVAL(result_set); /* Add all the subpatterns to it */ for (i=0; irefcount = 1; - object_handle->EA=0; + INIT_PZVAL(object_handle); zend_hash_index_update(object->value.obj.properties, 0, &object_handle, sizeof(pval *), NULL); pval_destructor(&function_name->element); } else { diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index ac1e716970..fd210e8568 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -1082,11 +1082,12 @@ void array_each(INTERNAL_FUNCTION_PARAMETERS) entry = *entry_ptr; /* add value elements */ - if (entry->EA) { + if (entry->EA.is_ref) { tmp = (pval *)emalloc(sizeof(pval)); *tmp = *entry; pval_copy_constructor(tmp); - tmp->EA=0; + tmp->EA.is_ref=0; + tmp->EA.locks = 0; tmp->refcount=0; entry=tmp; } @@ -1130,8 +1131,7 @@ void array_reset(INTERNAL_FUNCTION_PARAMETERS) *return_value = **entry; pval_copy_constructor(return_value); - return_value->refcount=1; - return_value->EA=0; + INIT_PZVAL(return_value); } void array_current(INTERNAL_FUNCTION_PARAMETERS) @@ -2362,8 +2362,7 @@ PHP_FUNCTION(extract) data = (zval *)emalloc(sizeof(zval)); *data = *entry; zval_copy_ctor(data); - data->EA = 0; - data->refcount = 1; + INIT_PZVAL(data); zend_hash_update(EG(active_symbol_table), finalname, strlen(finalname)+1, &data, sizeof(zval *), NULL); @@ -2392,8 +2391,7 @@ static void _compact_var(HashTable *eg_active_symbol_table, zval *return_value, data = (zval *)emalloc(sizeof(zval)); *data = *value; zval_copy_ctor(data); - data->EA = 0; - data->refcount = 1; + INIT_PZVAL(data); zend_hash_update(return_value->value.ht, entry->value.str.val, entry->value.str.len+1, &data, sizeof(zval *), NULL); @@ -2603,8 +2601,7 @@ static void _phpi_pop(INTERNAL_FUNCTION_PARAMETERS, int off_the_end) zend_hash_get_current_data(stack->value.ht, (void **)&val); *return_value = **val; zval_copy_ctor(return_value); - return_value->refcount=1; - return_value->EA=0; + INIT_PZVAL(return_value); /* Delete the first or last value */ new_hash = _phpi_splice(stack->value.ht, (off_the_end) ? -1 : 0, 1, NULL, 0, NULL); @@ -2919,8 +2916,7 @@ PHP_FUNCTION(array_keys) zend_hash_internal_pointer_reset(input->value.ht); while(zend_hash_get_current_data(input->value.ht, (void **)&entry) == SUCCESS) { new_val = (zval *)emalloc(sizeof(zval)); - new_val->EA = 0; - new_val->refcount = 1; + INIT_PZVAL(new_val); switch (zend_hash_get_current_key(input->value.ht, &string_key, &num_key)) { case HASH_KEY_IS_STRING: diff --git a/ext/standard/iptc.c b/ext/standard/iptc.c index 78843059f4..6c8224d1ed 100644 --- a/ext/standard/iptc.c +++ b/ext/standard/iptc.c @@ -368,8 +368,7 @@ PHP_FUNCTION(iptcparse) if (_php3_hash_find(return_value->value.ht,key,strlen(key) + 1,(void **) &element) == FAILURE) { values = emalloc(sizeof(pval)); - values->EA = 0; - values->refcount = 1; + INIT_PZVAL(values); if (array_init(values) == FAILURE) { php3_error(E_ERROR, "Unable to initialize array"); RETURN_FALSE; diff --git a/ext/standard/post.c b/ext/standard/post.c index 8d23632a73..45049662f5 100644 --- a/ext/standard/post.c +++ b/ext/standard/post.c @@ -143,8 +143,7 @@ static char *php3_getpost(pval *http_post_vars PLS_DC) postdata_ptr->type = IS_STRING; postdata_ptr->value.str.val = (char *) estrdup(buf); postdata_ptr->value.str.len = cnt; - postdata_ptr->refcount=1; - postdata_ptr->EA=0; + INIT_PZVAL(postdata_ptr); _php3_hash_add(&symbol_table, "HTTP_FDF_DATA", sizeof("HTTP_FDF_DATA"), postdata_ptr, sizeof(pval *),NULL); } #endif @@ -224,16 +223,14 @@ void _php3_parse_gpc_data(char *val, char *var, pval *track_vars_array) /* If the array doesn't exist, create it */ if (_php3_hash_find(EG(active_symbol_table), var, var_len+1, (void **) &arr_ptr) == FAILURE) { arr1 = (pval *) emalloc(sizeof(pval)); - arr1->refcount=1; - arr1->EA=0; + INIT_PZVAL(arr1); if (array_init(arr1)==FAILURE) { return; } _php3_hash_update(EG(active_symbol_table), var, var_len+1, &arr1, sizeof(pval *), NULL); if (track_vars_array) { arr2 = (pval *) emalloc(sizeof(pval)); - arr2->refcount=1; - arr2->EA=0; + INIT_PZVAL(arr2); if (array_init(arr2)==FAILURE) { return; } @@ -243,8 +240,7 @@ void _php3_parse_gpc_data(char *val, char *var, pval *track_vars_array) if ((*arr_ptr)->type!=IS_ARRAY) { if (--(*arr_ptr) > 0) { *arr_ptr = (pval *) emalloc(sizeof(pval)); - (*arr_ptr)->refcount=1; - (*arr_ptr)->EA=0; + INIT_PZVAL(*arr_ptr); } else { pval_destructor(*arr_ptr); } @@ -253,8 +249,7 @@ void _php3_parse_gpc_data(char *val, char *var, pval *track_vars_array) } if (track_vars_array) { arr2 = (pval *) emalloc(sizeof(pval)); - arr2->refcount=1; - arr2->EA=0; + INIT_PZVAL(arr2); if (array_init(arr2)==FAILURE) { return; } @@ -269,8 +264,7 @@ void _php3_parse_gpc_data(char *val, char *var, pval *track_vars_array) } /* Now create the element */ entry = (pval *) emalloc(sizeof(pval)); - entry->refcount=1; - entry->EA=0; + INIT_PZVAL(entry); entry->value.str.val = val; entry->value.str.len = val_len; entry->type = IS_STRING; @@ -303,8 +297,7 @@ void _php3_parse_gpc_data(char *val, char *var, pval *track_vars_array) pval *entry = (pval *) emalloc(sizeof(pval)); entry->type = IS_STRING; - entry->refcount=1; - entry->EA=0; + INIT_PZVAL(entry); entry->value.str.val = val; entry->value.str.len = val_len; _php3_hash_update(EG(active_symbol_table), var, var_len+1, (void *) &entry, sizeof(pval *),NULL); @@ -332,8 +325,7 @@ void php3_treat_data(int arg, char *str) if (PG(track_vars)) { array_ptr = (pval *) emalloc(sizeof(pval)); array_init(array_ptr); - array_ptr->refcount=1; - array_ptr->EA=0; + INIT_PZVAL(array_ptr); switch (arg) { case PARSE_POST: _php3_hash_add(&EG(symbol_table), "HTTP_POST_VARS", sizeof("HTTP_POST_VARS"), &array_ptr, sizeof(pval *),NULL); diff --git a/ext/standard/var.c b/ext/standard/var.c index c05b7a6dec..57b5e4e098 100644 --- a/ext/standard/var.c +++ b/ext/standard/var.c @@ -324,8 +324,7 @@ int php3api_var_unserialize(pval **rval, const char **p, const char *max) } else { (*rval)->type = IS_LONG; } - (*rval)->refcount = 1; - (*rval)->EA = 0; + INIT_PZVAL(*rval); (*rval)->value.lval = atol(q + 2); return 1; @@ -342,8 +341,7 @@ int php3api_var_unserialize(pval **rval, const char **p, const char *max) } (*p)++; (*rval)->type = IS_DOUBLE; - (*rval)->refcount = 1; - (*rval)->EA = 0; + INIT_PZVAL(*rval); (*rval)->value.dval = atof(q + 2); return 1; @@ -374,15 +372,13 @@ int php3api_var_unserialize(pval **rval, const char **p, const char *max) (*rval)->type = IS_STRING; (*rval)->value.str.val = str; (*rval)->value.str.len = i; - (*rval)->refcount = 1; - (*rval)->EA = 0; + INIT_PZVAL(*rval); return 1; case 'a': (*rval)->type = IS_ARRAY; - (*rval)->refcount = 1; - (*rval)->EA = 0; + INIT_PZVAL(*rval); (*p) += 2; i = atoi(*p); (*rval)->value.ht = (HashTable *) emalloc(sizeof(HashTable)); @@ -423,8 +419,7 @@ int php3api_var_unserialize(pval **rval, const char **p, const char *max) case 'o': (*rval)->type = IS_OBJECT; - (*rval)->refcount = 1; - (*rval)->EA = 0; + INIT_PZVAL(*rval); (*p) += 2; i = atoi(*p); (*rval)->value.obj.properties = (HashTable *) emalloc(sizeof(HashTable)); diff --git a/ext/xml/xml.c b/ext/xml/xml.c index 4734fc46d7..464bd57f14 100644 --- a/ext/xml/xml.c +++ b/ext/xml/xml.c @@ -109,8 +109,7 @@ static pval *php3i_long_pval(long value) ret->type = IS_LONG; ret->value.lval = value; - ret->EA = 0; - ret->refcount = 1; + INIT_PZVAL(ret); return ret; } @@ -121,8 +120,7 @@ static pval *php3i_string_pval(const char *str) ret->type = IS_STRING; ret->value.str.len = len; - ret->EA = 0; - ret->refcount = 1; + INIT_PZVAL(ret); ret->value.str.val = estrndup(str, len); return ret; } @@ -647,8 +645,7 @@ static void php3i_add_to_info(xml_parser *parser,char *name) return; } - values->EA = 0; - values->refcount = 1; + INIT_PZVAL(values); _php3_hash_update(parser->info->value.ht, name, strlen(name)+1, (void *) &values, sizeof(pval*), (void **) &element); } @@ -712,12 +709,10 @@ void php3i_xml_startElementHandler(void *userData, const char *name, int atcnt = 0; tag = emalloc(sizeof(pval)); - tag->EA = 0; - tag->refcount = 1; + INIT_PZVAL(tag); atr = emalloc(sizeof(pval)); - atr->EA = 0; - atr->refcount = 1; + INIT_PZVAL(atr); array_init(tag); array_init(atr); @@ -802,8 +797,7 @@ void php3i_xml_endElementHandler(void *userData, const char *name) tag = emalloc(sizeof(pval)); array_init(tag); - tag->EA = 0; - tag->refcount = 1; + INIT_PZVAL(tag); php3i_add_to_info(parser,((char *) name) + parser->toffset); diff --git a/main/main.c b/main/main.c index 1373a3c0f5..393a4636b5 100644 --- a/main/main.c +++ b/main/main.c @@ -944,8 +944,7 @@ int _php3_hash_environment(PLS_D ELS_DC) tmp->value.str.len = strlen(p + 1); tmp->value.str.val = estrndup(p + 1, tmp->value.str.len); tmp->type = IS_STRING; - tmp->refcount=1; - tmp->EA=0; + INIT_PZVAL(tmp); /* environmental variables never take precedence over get/post/cookie variables */ _php3_hash_add(&EG(symbol_table), t, p - *env + 1, &tmp, sizeof(pval *), NULL); efree(t); @@ -970,8 +969,7 @@ int _php3_hash_environment(PLS_D ELS_DC) tmp->value.str.len = 0; tmp->value.str.val = empty_string; } - tmp->refcount=1; - tmp->EA=0; + INIT_PZVAL(tmp); tmp->type = IS_STRING; _php3_hash_update(&EG(symbol_table), t, strlen(t)+1, &tmp, sizeof(pval *), NULL); } @@ -983,8 +981,7 @@ int _php3_hash_environment(PLS_D ELS_DC) tmp = (pval *) emalloc(sizeof(pval)); tmp->value.str.len = strlen(((request_rec *) SG(server_context))->uri); tmp->value.str.val = estrndup(((request_rec *) SG(server_context))->uri, tmp->value.str.len); - tmp->refcount=1; - tmp->EA=0; + INIT_PZVAL(tmp); tmp->type = IS_STRING; _php3_hash_update(&EG(symbol_table), "PHP_SELF", sizeof("PHP_SELF"), (void *) &tmp, sizeof(pval *), NULL); } @@ -998,8 +995,7 @@ int _php3_hash_environment(PLS_D ELS_DC) tmp->value.str.val = emalloc(((pi)?strlen(pi):0) + 1); tmp->value.str.len = _php3_sprintf(tmp->value.str.val, "%s", (pi ? pi : "")); /* SAFE */ tmp->type = IS_STRING; - tmp->refcount=1; - tmp->EA=0; + INIT_PZVAL(tmp); #else int l = 0; char *sn; @@ -1017,8 +1013,7 @@ int _php3_hash_environment(PLS_D ELS_DC) tmp->value.str.val = emalloc(l + 1); tmp->value.str.len = _php3_sprintf(tmp->value.str.val, "%s%s", (sn ? sn : ""), (pi ? pi : "")); /* SAFE */ tmp->type = IS_STRING; - tmp->refcount=1; - tmp->EA=0; + INIT_PZVAL(tmp); #endif _php3_hash_update(&EG(symbol_table), "PHP_SELF", sizeof("PHP_SELF"), (void *) & tmp, sizeof(pval *), NULL); } @@ -1043,8 +1038,7 @@ void _php3_build_argv(char *s ELS_DC) php3_error(E_WARNING, "Unable to create argv array"); } else { arr->type = IS_ARRAY; - arr->refcount=1; - arr->EA=0; + INIT_PZVAL(arr); _php3_hash_update(&EG(symbol_table), "argv", sizeof("argv"), &arr, sizeof(pval *), NULL); } /* now pick out individual entries */ @@ -1059,8 +1053,7 @@ void _php3_build_argv(char *s ELS_DC) tmp->type = IS_STRING; tmp->value.str.len = strlen(ss); tmp->value.str.val = estrndup(ss, tmp->value.str.len); - tmp->refcount=1; - tmp->EA=0; + INIT_PZVAL(tmp); count++; if (_php3_hash_next_index_insert(arr->value.ht, &tmp, sizeof(pval *), NULL)==FAILURE) { if (tmp->type == IS_STRING) { @@ -1077,8 +1070,7 @@ void _php3_build_argv(char *s ELS_DC) tmp = (pval *) emalloc(sizeof(pval)); tmp->value.lval = count; tmp->type = IS_LONG; - tmp->refcount=1; - tmp->EA=0; + INIT_PZVAL(tmp); _php3_hash_add(&EG(symbol_table), "argc", sizeof("argc"), &tmp, sizeof(pval *), NULL); } diff --git a/main/rfc1867.c b/main/rfc1867.c index 86f07fbbf7..018b174c90 100644 --- a/main/rfc1867.c +++ b/main/rfc1867.c @@ -61,8 +61,7 @@ void php_mime_split(char *buf, int cnt, char *boundary) if (PG(track_vars)) { http_post_vars = (pval *) emalloc(sizeof(pval)); array_init(http_post_vars); - http_post_vars->refcount=1; - http_post_vars->EA=0; + INIT_PZVAL(http_post_vars); zend_hash_add(&EG(symbol_table), "HTTP_POST_VARS", sizeof("HTTP_POST_VARS"), &http_post_vars, sizeof(pval *), NULL); }