summaryrefslogtreecommitdiff
path: root/ext/opcache/zend_shared_alloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/opcache/zend_shared_alloc.c')
-rw-r--r--ext/opcache/zend_shared_alloc.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/ext/opcache/zend_shared_alloc.c b/ext/opcache/zend_shared_alloc.c
index 249d99022a..17ddadbdd8 100644
--- a/ext/opcache/zend_shared_alloc.c
+++ b/ext/opcache/zend_shared_alloc.c
@@ -12,10 +12,10 @@
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
- | Authors: Andi Gutmans <andi@zend.com> |
- | Zeev Suraski <zeev@zend.com> |
+ | Authors: Andi Gutmans <andi@php.net> |
+ | Zeev Suraski <zeev@php.net> |
| Stanislav Malyshev <stas@zend.com> |
- | Dmitry Stogov <dmitry@zend.com> |
+ | Dmitry Stogov <dmitry@php.net> |
+----------------------------------------------------------------------+
*/
@@ -337,8 +337,10 @@ void *zend_shared_alloc(size_t size)
int zend_shared_memdup_size(void *source, size_t size)
{
void *old_p;
+ zend_ulong key = (zend_ulong)source;
- if ((old_p = zend_hash_index_find_ptr(&ZCG(xlat_table), (zend_ulong)source)) != NULL) {
+ key = (key >> 3) | (key << ((sizeof(key) * 8) - 3)); /* key = _rotr(key, 3);*/
+ if ((old_p = zend_hash_index_find_ptr(&ZCG(xlat_table), key)) != NULL) {
/* we already duplicated this pointer */
return 0;
}
@@ -349,8 +351,10 @@ int zend_shared_memdup_size(void *source, size_t size)
void *_zend_shared_memdup(void *source, size_t size, zend_bool free_source)
{
void *old_p, *retval;
+ zend_ulong key = (zend_ulong)source;
- if ((old_p = zend_hash_index_find_ptr(&ZCG(xlat_table), (zend_ulong)source)) != NULL) {
+ key = (key >> 3) | (key << ((sizeof(key) * 8) - 3)); /* key = _rotr(key, 3);*/
+ if ((old_p = zend_hash_index_find_ptr(&ZCG(xlat_table), key)) != NULL) {
/* we already duplicated this pointer */
return old_p;
}
@@ -443,14 +447,19 @@ void zend_shared_alloc_clear_xlat_table(void)
void zend_shared_alloc_register_xlat_entry(const void *old, const void *new)
{
- zend_hash_index_add_new_ptr(&ZCG(xlat_table), (zend_ulong)old, (void*)new);
+ zend_ulong key = (zend_ulong)old;
+
+ key = (key >> 3) | (key << ((sizeof(key) * 8) - 3)); /* key = _rotr(key, 3);*/
+ zend_hash_index_add_new_ptr(&ZCG(xlat_table), key, (void*)new);
}
void *zend_shared_alloc_get_xlat_entry(const void *old)
{
void *retval;
+ zend_ulong key = (zend_ulong)old;
- if ((retval = zend_hash_index_find_ptr(&ZCG(xlat_table), (zend_ulong)old)) == NULL) {
+ key = (key >> 3) | (key << ((sizeof(key) * 8) - 3)); /* key = _rotr(key, 3);*/
+ if ((retval = zend_hash_index_find_ptr(&ZCG(xlat_table), key)) == NULL) {
return NULL;
}
return retval;