summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2013-03-27 22:16:18 +0400
committerDmitry Stogov <dmitry@zend.com>2013-03-27 22:16:18 +0400
commit91ab11ed078f0fde6d17f278f7f3705c9fb38805 (patch)
tree1af3159dd11a8a81980670090cba751db49bfe72
parentfc7efecda05b85634b87311400842678985c66aa (diff)
downloadphp-git-91ab11ed078f0fde6d17f278f7f3705c9fb38805.tar.gz
Fixed issue #76 (actually we don't need zend_shared_memory_block_header at all)
-rw-r--r--ext/opcache/shared_alloc_win32.c2
-rw-r--r--ext/opcache/zend_shared_alloc.c14
-rw-r--r--ext/opcache/zend_shared_alloc.h4
3 files changed, 4 insertions, 16 deletions
diff --git a/ext/opcache/shared_alloc_win32.c b/ext/opcache/shared_alloc_win32.c
index e323952845..2c3218414d 100644
--- a/ext/opcache/shared_alloc_win32.c
+++ b/ext/opcache/shared_alloc_win32.c
@@ -166,7 +166,7 @@ static int zend_shared_alloc_reattach(size_t requested_size, char **error_in)
}
return ALLOC_FAIL_MAPPING;
}
- smm_shared_globals = (zend_smm_shared_globals *) (((char *) mapping_base) + sizeof(zend_shared_memory_block_header));
+ smm_shared_globals = (zend_smm_shared_globals *) mapping_base;
return SUCCESSFULLY_REATTACHED;
}
diff --git a/ext/opcache/zend_shared_alloc.c b/ext/opcache/zend_shared_alloc.c
index f4465ce78f..18e8bdb1f4 100644
--- a/ext/opcache/zend_shared_alloc.c
+++ b/ext/opcache/zend_shared_alloc.c
@@ -284,7 +284,7 @@ static size_t zend_shared_alloc_get_largest_free_block(void)
void *zend_shared_alloc(size_t size)
{
int i;
- unsigned int block_size = size + sizeof(zend_shared_memory_block_header);
+ unsigned int block_size = ZEND_ALIGNED_SIZE(size);
TSRMLS_FETCH();
#if 1
@@ -298,19 +298,11 @@ void *zend_shared_alloc(size_t size)
}
for (i = 0; i < ZSMMG(shared_segments_count); i++) {
if (ZSMMG(shared_segments)[i]->size - ZSMMG(shared_segments)[i]->pos >= block_size) { /* found a valid block */
- zend_shared_memory_block_header *p = (zend_shared_memory_block_header *) (((char *) ZSMMG(shared_segments)[i]->p) + ZSMMG(shared_segments)[i]->pos);
- int remainder = block_size % PLATFORM_ALIGNMENT;
- void *retval;
+ void *retval = (void *) (((char *) ZSMMG(shared_segments)[i]->p) + ZSMMG(shared_segments)[i]->pos);
- if (remainder != 0) {
- size += PLATFORM_ALIGNMENT - remainder;
- block_size += PLATFORM_ALIGNMENT - remainder;
- }
ZSMMG(shared_segments)[i]->pos += block_size;
ZSMMG(shared_free) -= block_size;
- p->size = size;
- retval = ((char *) p) + sizeof(zend_shared_memory_block_header);
- memset(retval, 0, size);
+ memset(retval, 0, block_size);
return retval;
}
}
diff --git a/ext/opcache/zend_shared_alloc.h b/ext/opcache/zend_shared_alloc.h
index 23af630f80..b7f36299bf 100644
--- a/ext/opcache/zend_shared_alloc.h
+++ b/ext/opcache/zend_shared_alloc.h
@@ -89,10 +89,6 @@ typedef struct _handler_entry {
zend_shared_memory_handlers *handler;
} zend_shared_memory_handler_entry;
-typedef struct _zend_shared_memory_block_header {
- int size;
-} zend_shared_memory_block_header;
-
typedef struct _zend_shared_memory_state {
int *positions; /* current positions for each segment */
int shared_free; /* amount of free shared memory */