Commit:    91ab11ed078f0fde6d17f278f7f3705c9fb38805
Author:    Dmitry Stogov <dmi...@zend.com>         Wed, 27 Mar 2013 22:16:18 
+0400
Parents:   fc7efecda05b85634b87311400842678985c66aa
Branches:  PHP-5.5 master

Link:       
http://git.php.net/?p=php-src.git;a=commitdiff;h=91ab11ed078f0fde6d17f278f7f3705c9fb38805

Log:
Fixed issue #76 (actually we don't need zend_shared_memory_block_header at all)

Bugs:
https://bugs.php.net/76

Changed paths:
  M  ext/opcache/shared_alloc_win32.c
  M  ext/opcache/zend_shared_alloc.c
  M  ext/opcache/zend_shared_alloc.h


Diff:
diff --git a/ext/opcache/shared_alloc_win32.c b/ext/opcache/shared_alloc_win32.c
index e323952..2c32184 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 f4465ce..18e8bdb 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 23af630..b7f3629 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 */


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to