diff options
author | Yiduo (David) Wang <davidw@php.net> | 2007-10-07 05:22:07 +0000 |
---|---|---|
committer | Yiduo (David) Wang <davidw@php.net> | 2007-10-07 05:22:07 +0000 |
commit | 4b4d634cb956de1efc13c8ed9b243fe1a85f783b (patch) | |
tree | eaa8d691de244aff3ee68fd3c23f769f02fa4446 /main | |
parent | ca4c55ad3a673257925bd9b458683c4f0e60e755 (diff) | |
download | php-git-4b4d634cb956de1efc13c8ed9b243fe1a85f783b.tar.gz |
MFH: Added macros for managing zval refcounts and is_ref statuses
Diffstat (limited to 'main')
-rw-r--r-- | main/output.c | 10 | ||||
-rw-r--r-- | main/php_ini.c | 4 | ||||
-rw-r--r-- | main/php_variables.c | 28 | ||||
-rw-r--r-- | main/streams/userspace.c | 32 |
4 files changed, 37 insertions, 37 deletions
diff --git a/main/output.c b/main/output.c index 5f36904c5e..b83eceff16 100644 --- a/main/output.c +++ b/main/output.c @@ -227,8 +227,8 @@ PHPAPI void php_end_ob_buffer(zend_bool send_buffer, zend_bool just_flush TSRMLS ALLOC_INIT_ZVAL(orig_buffer); ZVAL_STRINGL(orig_buffer, OG(active_ob_buffer).buffer, OG(active_ob_buffer).text_length, 1); - orig_buffer->refcount=2; /* don't let call_user_function() destroy our buffer */ - orig_buffer->is_ref=1; + Z_SET_REFCOUNT_P(orig_buffer, 2); /* don't let call_user_function() destroy our buffer */ + Z_SET_ISREF_P(orig_buffer); ALLOC_INIT_ZVAL(z_status); ZVAL_LONG(z_status, status); @@ -248,8 +248,8 @@ PHPAPI void php_end_ob_buffer(zend_bool send_buffer, zend_bool just_flush TSRMLS if (!just_flush) { zval_ptr_dtor(&OG(active_ob_buffer).output_handler); } - orig_buffer->refcount -=2; - if (orig_buffer->refcount <= 0) { /* free the zval */ + Z_SET_REFCOUNT_P(orig_buffer, Z_REFCOUNT_P(orig_buffer) - 2); + if (Z_REFCOUNT_P(orig_buffer) <= 0) { /* free the zval */ zval_dtor(orig_buffer); FREE_ZVAL(orig_buffer); } @@ -510,7 +510,7 @@ static int php_ob_init(uint initial_size, uint block_size, zval *output_handler, /* do we have array(object,method) */ if (zend_is_callable(output_handler, 0, &handler_name)) { SEPARATE_ZVAL(&output_handler); - output_handler->refcount++; + Z_ADDREF_P(output_handler); result = php_ob_init_named(initial_size, block_size, handler_name, output_handler, chunk_size, erase TSRMLS_CC); efree(handler_name); } else { diff --git a/main/php_ini.c b/main/php_ini.c index b9d8cce4a7..a570687d91 100644 --- a/main/php_ini.c +++ b/main/php_ini.c @@ -207,7 +207,7 @@ static void php_ini_parser_cb(zval *arg1, zval *arg2, zval *arg3, int callback_t copy = *arg2; zval_copy_ctor(©); - copy.refcount = 0; + Z_SET_REFCOUNT(copy, 0); zend_llist_add_element(&extension_lists.functions, ©); } else if (!strcasecmp(Z_STRVAL_P(arg1), ZEND_EXTENSION_TOKEN)) { /* load Zend extension */ char *extension_name = estrndup(Z_STRVAL_P(arg2), Z_STRLEN_P(arg2)); @@ -573,7 +573,7 @@ int php_init_config(TSRMLS_D) Z_STRLEN(tmp) = strlen(fh.filename); Z_STRVAL(tmp) = zend_strndup(fh.filename, Z_STRLEN(tmp)); Z_TYPE(tmp) = IS_STRING; - tmp.refcount = 0; + Z_SET_REFCOUNT(tmp, 0); zend_hash_update(&configuration_hash, "cfg_file_path", sizeof("cfg_file_path"), (void *) &tmp, sizeof(zval), NULL); if (php_ini_opened_path) { diff --git a/main/php_variables.c b/main/php_variables.c index bf52dae0e8..8ce0d5115a 100644 --- a/main/php_variables.c +++ b/main/php_variables.c @@ -517,14 +517,14 @@ static void php_build_argv(char *s, zval *track_vars_array TSRMLS_DC) Z_TYPE_P(argc) = IS_LONG; if (PG(register_globals) || SG(request_info).argc) { - arr->refcount++; - argc->refcount++; + Z_ADDREF_P(arr); + Z_ADDREF_P(argc); zend_hash_update(&EG(symbol_table), "argv", sizeof("argv"), &arr, sizeof(zval *), NULL); zend_hash_add(&EG(symbol_table), "argc", sizeof("argc"), &argc, sizeof(zval *), NULL); } if (track_vars_array) { - arr->refcount++; - argc->refcount++; + Z_ADDREF_P(arr); + Z_ADDREF_P(argc); zend_hash_update(Z_ARRVAL_P(track_vars_array), "argv", sizeof("argv"), &arr, sizeof(zval *), NULL); zend_hash_update(Z_ARRVAL_P(track_vars_array), "argc", sizeof("argc"), &argc, sizeof(zval *), NULL); } @@ -613,13 +613,13 @@ static void php_autoglobal_merge(HashTable *dest, HashTable *src TSRMLS_DC) || (key_type == HASH_KEY_IS_LONG && zend_hash_index_find(dest, num_key, (void **)&dest_entry) != SUCCESS) || Z_TYPE_PP(dest_entry) != IS_ARRAY ) { - (*src_entry)->refcount++; + Z_ADDREF_PP(src_entry); if (key_type == HASH_KEY_IS_STRING) { /* if register_globals is on and working with main symbol table, prevent overwriting of GLOBALS */ if (!globals_check || string_key_len != sizeof("GLOBALS") || memcmp(string_key, "GLOBALS", sizeof("GLOBALS") - 1)) { zend_hash_update(dest, string_key, string_key_len, src_entry, sizeof(zval *), NULL); } else { - (*src_entry)->refcount--; + Z_DELREF_PP(src_entry); } } else { zend_hash_index_update(dest, num_key, src_entry, sizeof(zval *), NULL); @@ -738,11 +738,11 @@ int php_hash_environment(TSRMLS_D) INIT_PZVAL(PG(http_globals)[i]); } - PG(http_globals)[i]->refcount++; + Z_ADDREF_P(PG(http_globals)[i]); zend_hash_update(&EG(symbol_table), auto_global_records[i].name, auto_global_records[i].name_len, &PG(http_globals)[i], sizeof(zval *), NULL); if (PG(register_long_arrays)) { zend_hash_update(&EG(symbol_table), auto_global_records[i].long_name, auto_global_records[i].long_name_len, &PG(http_globals)[i], sizeof(zval *), NULL); - PG(http_globals)[i]->refcount++; + Z_ADDREF_P(PG(http_globals)[i]); } } @@ -767,8 +767,8 @@ static zend_bool php_auto_globals_create_server(char *name, uint name_len TSRMLS if (zend_hash_find(&EG(symbol_table), "argc", sizeof("argc"), (void**)&argc) == SUCCESS && zend_hash_find(&EG(symbol_table), "argv", sizeof("argv"), (void**)&argv) == SUCCESS) { - (*argc)->refcount++; - (*argv)->refcount++; + Z_ADDREF_PP(argc); + Z_ADDREF_PP(argv); zend_hash_update(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER]), "argv", sizeof("argv"), argv, sizeof(zval *), NULL); zend_hash_update(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER]), "argc", sizeof("argc"), argc, sizeof(zval *), NULL); } @@ -789,11 +789,11 @@ static zend_bool php_auto_globals_create_server(char *name, uint name_len TSRMLS } zend_hash_update(&EG(symbol_table), name, name_len + 1, &PG(http_globals)[TRACK_VARS_SERVER], sizeof(zval *), NULL); - PG(http_globals)[TRACK_VARS_SERVER]->refcount++; + Z_ADDREF_P(PG(http_globals)[TRACK_VARS_SERVER]); if (PG(register_long_arrays)) { zend_hash_update(&EG(symbol_table), "HTTP_SERVER_VARS", sizeof("HTTP_SERVER_VARS"), &PG(http_globals)[TRACK_VARS_SERVER], sizeof(zval *), NULL); - PG(http_globals)[TRACK_VARS_SERVER]->refcount++; + Z_ADDREF_P(PG(http_globals)[TRACK_VARS_SERVER]); } return 0; /* don't rearm */ @@ -815,11 +815,11 @@ static zend_bool php_auto_globals_create_env(char *name, uint name_len TSRMLS_DC } zend_hash_update(&EG(symbol_table), name, name_len + 1, &PG(http_globals)[TRACK_VARS_ENV], sizeof(zval *), NULL); - PG(http_globals)[TRACK_VARS_ENV]->refcount++; + Z_ADDREF_P(PG(http_globals)[TRACK_VARS_ENV]); if (PG(register_long_arrays)) { zend_hash_update(&EG(symbol_table), "HTTP_ENV_VARS", sizeof("HTTP_ENV_VARS"), &PG(http_globals)[TRACK_VARS_ENV], sizeof(zval *), NULL); - PG(http_globals)[TRACK_VARS_ENV]->refcount++; + Z_ADDREF_P(PG(http_globals)[TRACK_VARS_ENV]); } return 0; /* don't rearm */ diff --git a/main/streams/userspace.c b/main/streams/userspace.c index e4901ffe54..13749effa5 100644 --- a/main/streams/userspace.c +++ b/main/streams/userspace.c @@ -242,8 +242,8 @@ static php_stream *user_wrapper_opener(php_stream_wrapper *wrapper, char *filena /* create an instance of our class */ ALLOC_ZVAL(us->object); object_init_ex(us->object, uwrap->ce); - ZVAL_REFCOUNT(us->object) = 1; - PZVAL_IS_REF(us->object) = 1; + Z_SET_REFCOUNT_P(us->object, 1); + Z_SET_ISREF_P(us->object); if (uwrap->ce->constructor) { zend_fcall_info fci; @@ -305,8 +305,8 @@ static php_stream *user_wrapper_opener(php_stream_wrapper *wrapper, char *filena args[2] = &zoptions; MAKE_STD_ZVAL(zopened); - ZVAL_REFCOUNT(zopened) = 1; - PZVAL_IS_REF(zopened) = 1; + Z_SET_REFCOUNT_P(zopened, 1); + Z_SET_ISREF_P(zopened); ZVAL_NULL(zopened); args[3] = &zopened; @@ -380,8 +380,8 @@ static php_stream *user_wrapper_opendir(php_stream_wrapper *wrapper, char *filen /* create an instance of our class */ ALLOC_ZVAL(us->object); object_init_ex(us->object, uwrap->ce); - ZVAL_REFCOUNT(us->object) = 1; - PZVAL_IS_REF(us->object) = 1; + Z_SET_REFCOUNT_P(us->object, 1); + Z_SET_ISREF_P(us->object); if (context) { MAKE_STD_ZVAL(zcontext); @@ -961,8 +961,8 @@ static int user_wrapper_unlink(php_stream_wrapper *wrapper, char *url, int optio /* create an instance of our class */ ALLOC_ZVAL(object); object_init_ex(object, uwrap->ce); - ZVAL_REFCOUNT(object) = 1; - PZVAL_IS_REF(object) = 1; + Z_SET_REFCOUNT_P(object, 1); + Z_SET_ISREF_P(object); if (context) { MAKE_STD_ZVAL(zcontext); @@ -1019,8 +1019,8 @@ static int user_wrapper_rename(php_stream_wrapper *wrapper, char *url_from, char /* create an instance of our class */ ALLOC_ZVAL(object); object_init_ex(object, uwrap->ce); - ZVAL_REFCOUNT(object) = 1; - PZVAL_IS_REF(object) = 1; + Z_SET_REFCOUNT_P(object, 1); + Z_SET_ISREF_P(object); if (context) { MAKE_STD_ZVAL(zcontext); @@ -1082,8 +1082,8 @@ static int user_wrapper_mkdir(php_stream_wrapper *wrapper, char *url, int mode, /* create an instance of our class */ ALLOC_ZVAL(object); object_init_ex(object, uwrap->ce); - ZVAL_REFCOUNT(object) = 1; - PZVAL_IS_REF(object) = 1; + Z_SET_REFCOUNT_P(object, 1); + Z_SET_ISREF_P(object); if (context) { MAKE_STD_ZVAL(zcontext); @@ -1151,8 +1151,8 @@ static int user_wrapper_rmdir(php_stream_wrapper *wrapper, char *url, int option /* create an instance of our class */ ALLOC_ZVAL(object); object_init_ex(object, uwrap->ce); - ZVAL_REFCOUNT(object) = 1; - PZVAL_IS_REF(object) = 1; + Z_SET_REFCOUNT_P(object, 1); + Z_SET_ISREF_P(object); if (context) { MAKE_STD_ZVAL(zcontext); @@ -1215,8 +1215,8 @@ static int user_wrapper_stat_url(php_stream_wrapper *wrapper, char *url, int fla /* create an instance of our class */ ALLOC_ZVAL(object); object_init_ex(object, uwrap->ce); - ZVAL_REFCOUNT(object) = 1; - PZVAL_IS_REF(object) = 1; + Z_SET_REFCOUNT_P(object, 1); + Z_SET_ISREF_P(object); if (context) { MAKE_STD_ZVAL(zcontext); |