]> granicus.if.org Git - php/commitdiff
Use better zend_hash_* functions
authorDmitry Stogov <dmitry@zend.com>
Fri, 5 Jun 2015 10:54:57 +0000 (13:54 +0300)
committerDmitry Stogov <dmitry@zend.com>
Fri, 5 Jun 2015 10:54:57 +0000 (13:54 +0300)
Zend/zend_hash.h
ext/opcache/zend_accelerator_util_funcs.c
ext/opcache/zend_shared_alloc.c

index 3ae3e4571bb4d7043a8c9cbdb2974a0d36671bf1..e55ee9e61ffe6cb0c217c4348ee26a1153927f36 100644 (file)
@@ -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;
index 990639aeb409b5622e178e605c367907372f85b9..9582b723a2b874b906e51b9ba556cc0efd701e2c 100644 (file)
 
 #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
 
index 19b51e7c59fa8f5090d66a57cb37abd2be11bcd8..ca50ab92193cd1b49dd1c15584ee08a37f5f00d3 100644 (file)
@@ -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)