mirror of
https://github.com/php/php-src.git
synced 2024-11-24 10:24:11 +08:00
- Added MAKE_COPY_ZVAL(ppzv, pzv) macro
This commit is contained in:
parent
a9044795da
commit
a94558c855
@ -710,6 +710,11 @@ END_EXTERN_C()
|
||||
FREE_ZVAL(pzv); \
|
||||
} \
|
||||
INIT_PZVAL(&(zv));
|
||||
|
||||
#define MAKE_COPY_ZVAL(ppzv, pzv) \
|
||||
*(pzv) = **(ppzv); \
|
||||
zval_copy_ctor((pzv)); \
|
||||
INIT_PZVAL((pzv));
|
||||
|
||||
#define REPLACE_ZVAL_VALUE(ppzv_dest, pzv_src, copy) { \
|
||||
int is_ref, refcount; \
|
||||
|
@ -392,9 +392,7 @@ static void php_zval_filter(zval **value, long filter, long flags, zval *options
|
||||
) {
|
||||
zval **tmp;
|
||||
if (zend_hash_find(HASH_OF(options), "default", sizeof("default"), (void **)&tmp) == SUCCESS) {
|
||||
**value = **tmp;
|
||||
zval_copy_ctor(*value);
|
||||
INIT_PZVAL(*value);
|
||||
MAKE_COPY_ZVAL(tmp, *value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -679,9 +677,7 @@ static void php_filter_call(zval **filtered, long filter, zval **filter_args, co
|
||||
zval *tmp;
|
||||
|
||||
ALLOC_ZVAL(tmp);
|
||||
*tmp = **filtered;
|
||||
zval_copy_ctor(tmp);
|
||||
INIT_PZVAL(tmp);
|
||||
MAKE_COPY_ZVAL(filtered, tmp);
|
||||
|
||||
zval_dtor(*filtered);
|
||||
|
||||
@ -701,15 +697,11 @@ static void php_filter_array_handler(zval *input, zval **op, zval *return_value
|
||||
|
||||
if (!op) {
|
||||
zval_dtor(return_value);
|
||||
*return_value = *input;
|
||||
zval_copy_ctor(return_value);
|
||||
INIT_PZVAL(return_value);
|
||||
MAKE_COPY_ZVAL(&input, return_value);
|
||||
php_filter_call(&return_value, FILTER_DEFAULT, NULL, 0, FILTER_REQUIRE_ARRAY TSRMLS_CC);
|
||||
} else if (Z_TYPE_PP(op) == IS_LONG) {
|
||||
zval_dtor(return_value);
|
||||
*return_value = *input;
|
||||
zval_copy_ctor(return_value);
|
||||
INIT_PZVAL(return_value);
|
||||
MAKE_COPY_ZVAL(&input, return_value);
|
||||
php_filter_call(&return_value, Z_LVAL_PP(op), NULL, 0, FILTER_REQUIRE_ARRAY TSRMLS_CC);
|
||||
} else if (Z_TYPE_PP(op) == IS_ARRAY) {
|
||||
array_init(return_value);
|
||||
@ -735,9 +727,7 @@ static void php_filter_array_handler(zval *input, zval **op, zval *return_value
|
||||
zval *nval;
|
||||
|
||||
ALLOC_ZVAL(nval);
|
||||
*nval = **tmp;
|
||||
zval_copy_ctor(nval);
|
||||
INIT_PZVAL(nval);
|
||||
MAKE_COPY_ZVAL(tmp, nval);
|
||||
|
||||
php_filter_call(&nval, -1, arg_elm, 0, FILTER_REQUIRE_SCALAR TSRMLS_CC);
|
||||
add_assoc_zval_ex(return_value, arg_key, arg_key_len, nval);
|
||||
@ -783,9 +773,7 @@ PHP_FUNCTION(filter_input)
|
||||
Z_TYPE_PP(opt) == IS_ARRAY &&
|
||||
zend_hash_find(HASH_OF(*opt), "default", sizeof("default"), (void **)&def) == SUCCESS
|
||||
) {
|
||||
*return_value = **def;
|
||||
zval_copy_ctor(return_value);
|
||||
INIT_PZVAL(return_value);
|
||||
MAKE_COPY_ZVAL(def, return_value);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -796,9 +784,7 @@ PHP_FUNCTION(filter_input)
|
||||
}
|
||||
}
|
||||
|
||||
*return_value = **tmp;
|
||||
zval_copy_ctor(return_value); /* Watch out for empty strings */
|
||||
INIT_PZVAL(return_value);
|
||||
MAKE_COPY_ZVAL(tmp, return_value);
|
||||
|
||||
php_filter_call(&return_value, filter, filter_args, 1, FILTER_REQUIRE_SCALAR TSRMLS_CC);
|
||||
}
|
||||
@ -820,9 +806,7 @@ PHP_FUNCTION(filter_var)
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
*return_value = *data;
|
||||
zval_copy_ctor(data);
|
||||
INIT_PZVAL(return_value);
|
||||
MAKE_COPY_ZVAL(&data, return_value);
|
||||
|
||||
php_filter_call(&return_value, filter, filter_args, 1, FILTER_REQUIRE_SCALAR TSRMLS_CC);
|
||||
}
|
||||
|
@ -1314,9 +1314,7 @@ static void preg_replace_impl(INTERNAL_FUNCTION_PARAMETERS, int is_callable_repl
|
||||
if (!zend_is_callable(*replace, 0, &callback_name TSRMLS_CC)) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Requires argument 2, '%s', to be a valid callback", callback_name);
|
||||
efree(callback_name);
|
||||
*return_value = **subject;
|
||||
zval_copy_ctor(return_value);
|
||||
INIT_PZVAL(return_value);
|
||||
MAKE_COPY_ZVAL(subject, return_value);
|
||||
return;
|
||||
}
|
||||
efree(callback_name);
|
||||
|
@ -469,9 +469,7 @@ static PHP_METHOD(PDOStatement, execute)
|
||||
|
||||
param.param_type = PDO_PARAM_STR;
|
||||
MAKE_STD_ZVAL(param.parameter);
|
||||
*param.parameter = **tmp;
|
||||
zval_copy_ctor(param.parameter);
|
||||
INIT_PZVAL(param.parameter);
|
||||
MAKE_COPY_ZVAL(tmp, param.parameter);
|
||||
|
||||
if (!really_register_bound_param(¶m, stmt, 1 TSRMLS_CC)) {
|
||||
if (param.parameter) {
|
||||
@ -1277,9 +1275,7 @@ static int do_fetch(pdo_stmt_t *stmt, int do_bind, zval *return_value,
|
||||
zval_ptr_dtor(&return_value); /* we don't need that */
|
||||
return_value = retval;
|
||||
} else if (retval) {
|
||||
*return_value = *retval;
|
||||
zval_copy_ctor(return_value);
|
||||
INIT_PZVAL(return_value);
|
||||
MAKE_COPY_ZVAL(&retval, return_value);
|
||||
zval_ptr_dtor(&retval);
|
||||
}
|
||||
}
|
||||
|
@ -496,9 +496,7 @@ static PHP_METHOD(SQLite, sqliteCreateFunction)
|
||||
func->funcname = estrdup(func_name);
|
||||
|
||||
MAKE_STD_ZVAL(func->func);
|
||||
*(func->func) = *callback;
|
||||
zval_copy_ctor(func->func);
|
||||
INIT_PZVAL(func->func);
|
||||
MAKE_COPY_ZVAL(&callback, func->func);
|
||||
|
||||
func->argc = argc;
|
||||
|
||||
@ -575,14 +573,10 @@ static PHP_METHOD(SQLite, sqliteCreateAggregate)
|
||||
func->funcname = estrdup(func_name);
|
||||
|
||||
MAKE_STD_ZVAL(func->step);
|
||||
*(func->step) = *step_callback;
|
||||
zval_copy_ctor(func->step);
|
||||
INIT_PZVAL(func->step);
|
||||
MAKE_COPY_ZVAL(&step_callback, func->step);
|
||||
|
||||
MAKE_STD_ZVAL(func->fini);
|
||||
*(func->fini) = *fini_callback;
|
||||
zval_copy_ctor(func->fini);
|
||||
INIT_PZVAL(func->fini);
|
||||
MAKE_COPY_ZVAL(&fini_callback, func->fini);
|
||||
|
||||
func->argc = argc;
|
||||
|
||||
|
@ -213,9 +213,7 @@ static void _default_get_entry(zval *object, char *name, int name_len, zval *ret
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
*return_value = **value;
|
||||
zval_copy_ctor(return_value);
|
||||
INIT_PZVAL(return_value);
|
||||
MAKE_COPY_ZVAL(value, return_value);
|
||||
}
|
||||
|
||||
#ifdef ilia_0
|
||||
@ -3087,9 +3085,7 @@ ZEND_METHOD(reflection_class, getStaticProperties)
|
||||
if (!(class_name && class_name[0] != '*' && strcmp(class_name, ce->name))) {
|
||||
/* copy: enforce read only access */
|
||||
ALLOC_ZVAL(prop_copy);
|
||||
*prop_copy = **value;
|
||||
zval_copy_ctor(prop_copy);
|
||||
INIT_PZVAL(prop_copy);
|
||||
MAKE_COPY_ZVAL(value, prop_copy);
|
||||
|
||||
add_assoc_zval(return_value, prop_name, prop_copy);
|
||||
}
|
||||
@ -3212,9 +3208,7 @@ ZEND_METHOD(reflection_class, getDefaultProperties)
|
||||
|
||||
/* copy: enforce read only access */
|
||||
ALLOC_ZVAL(prop_copy);
|
||||
*prop_copy = **prop;
|
||||
zval_copy_ctor(prop_copy);
|
||||
INIT_PZVAL(prop_copy);
|
||||
MAKE_COPY_ZVAL(prop, prop_copy);
|
||||
|
||||
add_assoc_zval(return_value, prop_name, prop_copy);
|
||||
}
|
||||
@ -3746,9 +3740,7 @@ ZEND_METHOD(reflection_class, getConstant)
|
||||
if (zend_hash_find(&ce->constants_table, name, name_len + 1, (void **) &value) == FAILURE) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
*return_value = **value;
|
||||
zval_copy_ctor(return_value);
|
||||
INIT_PZVAL(return_value);
|
||||
MAKE_COPY_ZVAL(value, return_value);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@ -4531,9 +4523,7 @@ ZEND_METHOD(reflection_property, getValue)
|
||||
zend_error(E_ERROR, "Internal error: Could not find the property %s::%s", intern->ce->name, ref->prop.name);
|
||||
/* Bails out */
|
||||
}
|
||||
*return_value= **member;
|
||||
zval_copy_ctor(return_value);
|
||||
INIT_PZVAL(return_value);
|
||||
MAKE_COPY_ZVAL(member, return_value);
|
||||
} else {
|
||||
char *class_name, *prop_name;
|
||||
|
||||
@ -4542,9 +4532,7 @@ ZEND_METHOD(reflection_property, getValue)
|
||||
}
|
||||
zend_unmangle_property_name(ref->prop.name, ref->prop.name_length, &class_name, &prop_name);
|
||||
member_p = zend_read_property(ref->ce, object, prop_name, strlen(prop_name), 1 TSRMLS_CC);
|
||||
*return_value= *member_p;
|
||||
zval_copy_ctor(return_value);
|
||||
INIT_PZVAL(return_value);
|
||||
MAKE_COPY_ZVAL(&member_p, return_value);
|
||||
if (member_p != EG(uninitialized_zval_ptr)) {
|
||||
zval_add_ref(&member_p);
|
||||
zval_ptr_dtor(&member_p);
|
||||
|
@ -1416,9 +1416,7 @@ PHP_METHOD(SoapServer, setObject)
|
||||
service->type = SOAP_OBJECT;
|
||||
|
||||
MAKE_STD_ZVAL(service->soap_object);
|
||||
*service->soap_object = *obj;
|
||||
zval_copy_ctor(service->soap_object);
|
||||
INIT_PZVAL(service->soap_object);
|
||||
MAKE_COPY_ZVAL(&obj, service->soap_object);
|
||||
|
||||
SOAP_SERVER_END_CODE();
|
||||
}
|
||||
@ -2335,9 +2333,7 @@ static void soap_error_handler(int error_num, const char *error_filename, const
|
||||
}
|
||||
fault = add_soap_fault(SOAP_GLOBAL(error_object), code, buffer, NULL, NULL TSRMLS_CC);
|
||||
MAKE_STD_ZVAL(exception);
|
||||
*exception = *fault;
|
||||
zval_copy_ctor(exception);
|
||||
INIT_PZVAL(exception);
|
||||
MAKE_COPY_ZVAL(&fault, exception);
|
||||
zend_throw_exception_object(exception TSRMLS_CC);
|
||||
|
||||
old_objects = EG(objects_store).object_buckets;
|
||||
@ -2623,9 +2619,7 @@ PHP_METHOD(SoapClient, SoapClient)
|
||||
zval *class_map;
|
||||
|
||||
MAKE_STD_ZVAL(class_map);
|
||||
*class_map = **tmp;
|
||||
INIT_PZVAL(class_map);
|
||||
zval_copy_ctor(class_map);
|
||||
MAKE_COPY_ZVAL(tmp, class_map);
|
||||
#ifdef ZEND_ENGINE_2
|
||||
Z_DELREF_P(class_map);
|
||||
#endif
|
||||
@ -2955,9 +2949,7 @@ static void do_soap_call(zval* this_ptr,
|
||||
zval *exception;
|
||||
|
||||
MAKE_STD_ZVAL(exception);
|
||||
*exception = *return_value;
|
||||
zval_copy_ctor(exception);
|
||||
INIT_PZVAL(exception);
|
||||
MAKE_COPY_ZVAL(&return_value, exception);
|
||||
zend_throw_exception_object(exception TSRMLS_CC);
|
||||
}
|
||||
#endif
|
||||
|
@ -2382,10 +2382,8 @@ SPL_METHOD(CachingIterator, __toString)
|
||||
return;
|
||||
}
|
||||
} else if (intern->u.caching.flags & CIT_TOSTRING_USE_CURRENT) {
|
||||
*return_value = *intern->current.data;
|
||||
zval_copy_ctor(return_value);
|
||||
MAKE_COPY_ZVAL(&intern->current.data, return_value);
|
||||
convert_to_string(return_value);
|
||||
INIT_PZVAL(return_value);
|
||||
return;
|
||||
}
|
||||
if (intern->u.caching.zstr) {
|
||||
|
@ -851,9 +851,7 @@ PHP_METHOD(sqlite3, createFunction)
|
||||
func->func_name = estrdup(sql_func);
|
||||
|
||||
MAKE_STD_ZVAL(func->func);
|
||||
*(func->func) = *callback_func;
|
||||
zval_copy_ctor(func->func);
|
||||
INIT_PZVAL(func->func);
|
||||
MAKE_COPY_ZVAL(&callback_func, func->func);
|
||||
|
||||
func->argc = sql_func_num_args;
|
||||
func->next = db_obj->funcs;
|
||||
@ -910,14 +908,10 @@ PHP_METHOD(sqlite3, createAggregate)
|
||||
func->func_name = estrdup(sql_func);
|
||||
|
||||
MAKE_STD_ZVAL(func->step);
|
||||
*(func->step) = *step_callback;
|
||||
zval_copy_ctor(func->step);
|
||||
INIT_PZVAL(func->step);
|
||||
MAKE_COPY_ZVAL(&step_callback, func->step);
|
||||
|
||||
MAKE_STD_ZVAL(func->fini);
|
||||
*(func->fini) = *fini_callback;
|
||||
zval_copy_ctor(func->fini);
|
||||
INIT_PZVAL(func->fini);
|
||||
MAKE_COPY_ZVAL(&fini_callback, func->fini);
|
||||
|
||||
func->argc = sql_func_num_args;
|
||||
func->next = db_obj->funcs;
|
||||
|
@ -1464,9 +1464,7 @@ static void php_compact_var(HashTable *eg_active_symbol_table, zval *return_valu
|
||||
if (zend_hash_find(eg_active_symbol_table, Z_STRVAL_P(entry), Z_STRLEN_P(entry) + 1, (void **)&value_ptr) != FAILURE) {
|
||||
value = *value_ptr;
|
||||
ALLOC_ZVAL(data);
|
||||
*data = *value;
|
||||
zval_copy_ctor(data);
|
||||
INIT_PZVAL(data);
|
||||
MAKE_COPY_ZVAL(&value, data);
|
||||
|
||||
zend_hash_update(Z_ARRVAL_P(return_value), Z_STRVAL_P(entry), Z_STRLEN_P(entry) + 1, &data, sizeof(zval *), NULL);
|
||||
}
|
||||
@ -4089,9 +4087,7 @@ PHP_FUNCTION(array_reduce)
|
||||
|
||||
if (ZEND_NUM_ARGS() > 2) {
|
||||
ALLOC_ZVAL(result);
|
||||
*result = *initial;
|
||||
zval_copy_ctor(result);
|
||||
INIT_PZVAL(result);
|
||||
MAKE_COPY_ZVAL(&initial, result);
|
||||
} else {
|
||||
MAKE_STD_ZVAL(result);
|
||||
ZVAL_NULL(result);
|
||||
|
@ -5837,9 +5837,7 @@ static void php_simple_ini_parser_cb(zval *arg1, zval *arg2, zval *arg3, int cal
|
||||
break;
|
||||
}
|
||||
ALLOC_ZVAL(element);
|
||||
*element = *arg2;
|
||||
zval_copy_ctor(element);
|
||||
INIT_PZVAL(element);
|
||||
MAKE_COPY_ZVAL(&arg2, element);
|
||||
zend_symtable_update(Z_ARRVAL_P(arr), Z_STRVAL_P(arg1), Z_STRLEN_P(arg1) + 1, &element, sizeof(zval *), NULL);
|
||||
break;
|
||||
|
||||
@ -5882,9 +5880,7 @@ static void php_simple_ini_parser_cb(zval *arg1, zval *arg2, zval *arg3, int cal
|
||||
}
|
||||
|
||||
ALLOC_ZVAL(element);
|
||||
*element = *arg2;
|
||||
zval_copy_ctor(element);
|
||||
INIT_PZVAL(element);
|
||||
MAKE_COPY_ZVAL(&arg2, element);
|
||||
|
||||
if (arg3 && Z_STRLEN_P(arg3) > 0) {
|
||||
add_assoc_zval_ex(hash, Z_STRVAL_P(arg3), Z_STRLEN_P(arg3) + 1, element);
|
||||
|
@ -484,9 +484,7 @@ PHP_FUNCTION(stream_get_meta_data)
|
||||
|
||||
if (stream->wrapperdata) {
|
||||
MAKE_STD_ZVAL(newval);
|
||||
*newval = *(stream->wrapperdata);
|
||||
zval_copy_ctor(newval);
|
||||
INIT_PZVAL(newval);
|
||||
MAKE_COPY_ZVAL(&stream->wrapperdata, newval);
|
||||
|
||||
add_assoc_zval(return_value, "wrapper_data", newval);
|
||||
}
|
||||
|
@ -3530,9 +3530,7 @@ static void php_str_replace_in_subject(zval *search, zval *replace, zval **subje
|
||||
/* If search is an array */
|
||||
if (Z_TYPE_P(search) == IS_ARRAY) {
|
||||
/* Duplicate subject string for repeated replacement */
|
||||
*result = **subject;
|
||||
zval_copy_ctor(result);
|
||||
INIT_PZVAL(result);
|
||||
MAKE_COPY_ZVAL(subject, result);
|
||||
|
||||
zend_hash_internal_pointer_reset(Z_ARRVAL_P(search));
|
||||
|
||||
@ -3616,9 +3614,7 @@ static void php_str_replace_in_subject(zval *search, zval *replace, zval **subje
|
||||
Z_STRVAL_P(search), Z_STRLEN_P(search),
|
||||
Z_STRVAL_P(replace), Z_STRLEN_P(replace), &Z_STRLEN_P(result), case_sensitivity, replace_count);
|
||||
} else {
|
||||
*result = **subject;
|
||||
zval_copy_ctor(result);
|
||||
INIT_PZVAL(result);
|
||||
MAKE_COPY_ZVAL(subject, result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1270,9 +1270,7 @@ PHP_FUNCTION(xml_set_object)
|
||||
#endif */
|
||||
|
||||
ALLOC_ZVAL(parser->object);
|
||||
*parser->object = *mythis;
|
||||
zval_copy_ctor(parser->object);
|
||||
INIT_PZVAL(parser->object);
|
||||
MAKE_COPY_ZVAL(&mythis, parser->object);
|
||||
|
||||
RETVAL_TRUE;
|
||||
}
|
||||
|
@ -570,9 +570,7 @@ static XMLRPC_VALUE PHP_to_XMLRPC_worker (const char* key, zval* in_val, int dep
|
||||
}
|
||||
|
||||
MAKE_STD_ZVAL(val_arr);
|
||||
*val_arr = *val;
|
||||
zval_copy_ctor(val_arr);
|
||||
INIT_PZVAL(val_arr);
|
||||
MAKE_COPY_ZVAL(&val, val_arr);
|
||||
convert_to_array(val_arr);
|
||||
|
||||
vtype = determine_vector_type(Z_ARRVAL_P(val_arr));
|
||||
|
Loading…
Reference in New Issue
Block a user