ext/opcache refactoring (incomplete)

This commit is contained in:
Dmitry Stogov 2014-03-28 23:34:49 +04:00
parent 3647fc6fcc
commit 5324f22f59
17 changed files with 818 additions and 884 deletions

View file

@ -325,9 +325,9 @@ void *zend_shared_alloc(size_t size)
int zend_shared_memdup_size(void *source, size_t size)
{
void **old_p;
void *old_p;
if (zend_hash_index_find(&xlat_table, (ulong)source, (void **)&old_p) == SUCCESS) {
if ((old_p = zend_hash_index_find_ptr(&xlat_table, (ulong)source)) != NULL) {
/* we already duplicated this pointer */
return 0;
}
@ -337,17 +337,17 @@ int zend_shared_memdup_size(void *source, size_t size)
void *_zend_shared_memdup(void *source, size_t size, zend_bool free_source TSRMLS_DC)
{
void **old_p, *retval;
void *old_p, *retval;
if (zend_hash_index_find(&xlat_table, (ulong)source, (void **)&old_p) == SUCCESS) {
if ((old_p = zend_hash_index_find_ptr(&xlat_table, (ulong)source)) != NULL) {
/* we already duplicated this pointer */
return *old_p;
return old_p;
}
retval = ZCG(mem);;
ZCG(mem) = (void*)(((char*)ZCG(mem)) + ZEND_ALIGNED_SIZE(size));
memcpy(retval, source, size);
if (free_source) {
interned_efree((char*)source);
//??? interned_efree((char*)source);
}
zend_shared_alloc_register_xlat_entry(source, retval);
return retval;
@ -431,17 +431,17 @@ 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(&xlat_table, (ulong)old, (void*)&new, sizeof(void *), NULL);
zend_hash_index_update_ptr(&xlat_table, (ulong)old, (void*)new);
}
void *zend_shared_alloc_get_xlat_entry(const void *old)
{
void **retval;
void *retval;
if (zend_hash_index_find(&xlat_table, (ulong)old, (void **)&retval) == FAILURE) {
if ((retval = zend_hash_index_find_ptr(&xlat_table, (ulong)old)) == NULL) {
return NULL;
}
return *retval;
return retval;
}
size_t zend_shared_alloc_get_free_memory(void)