diff options
author | Dmitry Stogov <dmitry@zend.com> | 2018-12-19 17:24:56 +0300 |
---|---|---|
committer | Dmitry Stogov <dmitry@zend.com> | 2018-12-19 17:24:56 +0300 |
commit | 493f8303559c0f2ff88c1c245513ece86fadde27 (patch) | |
tree | b84c6b018812135d185d21f4088ec33156df579f /Zend/zend_API.c | |
parent | d356f6d72b1aa2abe27ba4d135174646b3a4c03a (diff) | |
download | php-git-493f8303559c0f2ff88c1c245513ece86fadde27.tar.gz |
Reuse add_property_zval_ex() instead of code duplication
Diffstat (limited to 'Zend/zend_API.c')
-rw-r--r-- | Zend/zend_API.c | 44 |
1 files changed, 8 insertions, 36 deletions
diff --git a/Zend/zend_API.c b/Zend/zend_API.c index fc33d93791..02b89be61b 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -1645,52 +1645,37 @@ ZEND_API int array_set_zval_key(HashTable *ht, zval *key, zval *value) /* {{{ */ ZEND_API int add_property_long_ex(zval *arg, const char *key, size_t key_len, zend_long n) /* {{{ */ { zval tmp; - zval z_key; ZVAL_LONG(&tmp, n); - ZVAL_STRINGL(&z_key, key, key_len); - Z_OBJ_HANDLER_P(arg, write_property)(arg, &z_key, &tmp, NULL); - zval_ptr_dtor(&z_key); - return SUCCESS; + return add_property_zval_ex(arg, key, key_len, &tmp); } /* }}} */ ZEND_API int add_property_bool_ex(zval *arg, const char *key, size_t key_len, zend_long b) /* {{{ */ { zval tmp; - zval z_key; ZVAL_BOOL(&tmp, b); - ZVAL_STRINGL(&z_key, key, key_len); - Z_OBJ_HANDLER_P(arg, write_property)(arg, &z_key, &tmp, NULL); - zval_ptr_dtor(&z_key); - return SUCCESS; + return add_property_zval_ex(arg, key, key_len, &tmp); } /* }}} */ ZEND_API int add_property_null_ex(zval *arg, const char *key, size_t key_len) /* {{{ */ { zval tmp; - zval z_key; ZVAL_NULL(&tmp); - ZVAL_STRINGL(&z_key, key, key_len); - Z_OBJ_HANDLER_P(arg, write_property)(arg, &z_key, &tmp, NULL); - zval_ptr_dtor(&z_key); - return SUCCESS; + return add_property_zval_ex(arg, key, key_len, &tmp); } /* }}} */ ZEND_API int add_property_resource_ex(zval *arg, const char *key, size_t key_len, zend_resource *r) /* {{{ */ { zval tmp; - zval z_key; ZVAL_RES(&tmp, r); - ZVAL_STRINGL(&z_key, key, key_len); - Z_OBJ_HANDLER_P(arg, write_property)(arg, &z_key, &tmp, NULL); + add_property_zval_ex(arg, key, key_len, &tmp); zval_ptr_dtor(&tmp); /* write_property will add 1 to refcount */ - zval_ptr_dtor(&z_key); return SUCCESS; } /* }}} */ @@ -1698,26 +1683,19 @@ ZEND_API int add_property_resource_ex(zval *arg, const char *key, size_t key_len ZEND_API int add_property_double_ex(zval *arg, const char *key, size_t key_len, double d) /* {{{ */ { zval tmp; - zval z_key; ZVAL_DOUBLE(&tmp, d); - ZVAL_STRINGL(&z_key, key, key_len); - Z_OBJ_HANDLER_P(arg, write_property)(arg, &z_key, &tmp, NULL); - zval_ptr_dtor(&z_key); - return SUCCESS; + return add_property_zval_ex(arg, key, key_len, &tmp); } /* }}} */ ZEND_API int add_property_str_ex(zval *arg, const char *key, size_t key_len, zend_string *str) /* {{{ */ { zval tmp; - zval z_key; ZVAL_STR(&tmp, str); - ZVAL_STRINGL(&z_key, key, key_len); - Z_OBJ_HANDLER_P(arg, write_property)(arg, &z_key, &tmp, NULL); + add_property_zval_ex(arg, key, key_len, &tmp); zval_ptr_dtor(&tmp); /* write_property will add 1 to refcount */ - zval_ptr_dtor(&z_key); return SUCCESS; } /* }}} */ @@ -1725,13 +1703,10 @@ ZEND_API int add_property_str_ex(zval *arg, const char *key, size_t key_len, zen ZEND_API int add_property_string_ex(zval *arg, const char *key, size_t key_len, const char *str) /* {{{ */ { zval tmp; - zval z_key; ZVAL_STRING(&tmp, str); - ZVAL_STRINGL(&z_key, key, key_len); - Z_OBJ_HANDLER_P(arg, write_property)(arg, &z_key, &tmp, NULL); + add_property_zval_ex(arg, key, key_len, &tmp); zval_ptr_dtor(&tmp); /* write_property will add 1 to refcount */ - zval_ptr_dtor(&z_key); return SUCCESS; } /* }}} */ @@ -1739,13 +1714,10 @@ ZEND_API int add_property_string_ex(zval *arg, const char *key, size_t key_len, ZEND_API int add_property_stringl_ex(zval *arg, const char *key, size_t key_len, const char *str, size_t length) /* {{{ */ { zval tmp; - zval z_key; ZVAL_STRINGL(&tmp, str, length); - ZVAL_STRINGL(&z_key, key, key_len); - Z_OBJ_HANDLER_P(arg, write_property)(arg, &z_key, &tmp, NULL); + add_property_zval_ex(arg, key, key_len, &tmp); zval_ptr_dtor(&tmp); /* write_property will add 1 to refcount */ - zval_ptr_dtor(&z_key); return SUCCESS; } /* }}} */ |