com php-src: Use better zend_hash_* functions: Zend/z end_hash.h ext/opcache/zend_accelerator_util_funcs .c ext/opcache/zend_shared_alloc.c
| From: | Dmitry Stogov | Date: | Fri, 05 Jun 2015 10:54:57 +0000 |
| Subject: | com php-src: Use better zend_hash_* functions: Zend/z end_hash.h ext/opcache/zend_accelerator_util_funcs .c ext/opcache/zend_shared_alloc.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-87072@lists.php.net to get a copy of this message | ||
Commit: 869f662cddcba81b03cb95651c7fdbe06f4b3458
Author: Dmitry Stogov <dmitry@zend.com> Fri, 5 Jun 2015 13:54:57 +0300
Parents: 3186f913ebafad6cb272d85c4f3a34288b3da50c
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=869f662cddcba81b03cb95651c7fdbe06f4b3458
Log:
Use better zend_hash_* functions
Changed paths:
M Zend/zend_hash.h
M ext/opcache/zend_accelerator_util_funcs.c
M ext/opcache/zend_shared_alloc.c
Diff:
diff --git a/Zend/zend_hash.h b/Zend/zend_hash.h
index 3ae3e45..e55ee9e 100644
--- a/Zend/zend_hash.h
+++ b/Zend/zend_hash.h
@@ -589,6 +589,15 @@ static zend_always_inline void *zend_hash_index_add_ptr(HashTable *ht,
zend_ulon
return zv ? Z_PTR_P(zv) : NULL;
}
+static zend_always_inline void *zend_hash_index_add_new_ptr(HashTable *ht, zend_ulong h, void
*pData)
+{
+ zval tmp, *zv;
+
+ ZVAL_PTR(&tmp, pData);
+ zv = zend_hash_index_add_new(ht, h, &tmp);
+ return zv ? Z_PTR_P(zv) : NULL;
+}
+
static zend_always_inline void *zend_hash_index_update_ptr(HashTable *ht, zend_ulong h, void
*pData)
{
zval tmp, *zv;
diff --git a/ext/opcache/zend_accelerator_util_funcs.c b/ext/opcache/zend_accelerator_util_funcs.c
index 990639a..9582b72 100644
--- a/ext/opcache/zend_accelerator_util_funcs.c
+++ b/ext/opcache/zend_accelerator_util_funcs.c
@@ -27,10 +27,10 @@
#if SIZEOF_SIZE_T <= SIZEOF_ZEND_LONG
/* If sizeof(void*) == sizeof(ulong) we can use zend_hash index functions */
-# define accel_xlat_set(old, new) zend_hash_index_update_ptr(&ZCG(bind_hash),
(zend_ulong)(zend_uintptr_t)(old), (new))
+# define accel_xlat_set(old, new) zend_hash_index_add_new_ptr(&ZCG(bind_hash),
(zend_ulong)(zend_uintptr_t)(old), (new))
# define accel_xlat_get(old) zend_hash_index_find_ptr(&ZCG(bind_hash),
(zend_ulong)(zend_uintptr_t)(old))
#else
-# define accel_xlat_set(old, new) (zend_hash_str_add_ptr(&ZCG(bind_hash), (char*)&(old),
sizeof(void*), (zend_ulong)(zend_uintptr_t)(old), (void**)&(new))
+# define accel_xlat_set(old, new) (zend_hash_str_add_new_ptr(&ZCG(bind_hash),
(char*)&(old), sizeof(void*), (zend_ulong)(zend_uintptr_t)(old), (void**)&(new))
# define accel_xlat_get(old, new) ((new) = zend_hash_str_find_ptr(&ZCG(bind_hash),
(char*)&(old), sizeof(void*), (zend_ulong)(zend_uintptr_t)(old), (void**)&(new)))
#endif
diff --git a/ext/opcache/zend_shared_alloc.c b/ext/opcache/zend_shared_alloc.c
index 19b51e7..ca50ab9 100644
--- a/ext/opcache/zend_shared_alloc.c
+++ b/ext/opcache/zend_shared_alloc.c
@@ -435,7 +435,7 @@ void zend_shared_alloc_clear_xlat_table(void)
void zend_shared_alloc_register_xlat_entry(const void *old, const void *new)
{
- zend_hash_index_update_ptr(&ZCG(xlat_table), (zend_ulong)old, (void*)new);
+ zend_hash_index_add_new_ptr(&ZCG(xlat_table), (zend_ulong)old, (void*)new);
}
void *zend_shared_alloc_get_xlat_entry(const void *old)