Skip to content

Commit 36861bf

Browse files
committed
Merge branch 'PHP-5.5'
* PHP-5.5: Fixed issue #76 (actually we don't need zend_shared_memory_block_header at all)
2 parents 34ac5c9 + 91ab11e commit 36861bf

File tree

3 files changed

+4
-16
lines changed

3 files changed

+4
-16
lines changed

ext/opcache/shared_alloc_win32.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ static int zend_shared_alloc_reattach(size_t requested_size, char **error_in)
166166
}
167167
return ALLOC_FAIL_MAPPING;
168168
}
169-
smm_shared_globals = (zend_smm_shared_globals *) (((char *) mapping_base) + sizeof(zend_shared_memory_block_header));
169+
smm_shared_globals = (zend_smm_shared_globals *) mapping_base;
170170

171171
return SUCCESSFULLY_REATTACHED;
172172
}

ext/opcache/zend_shared_alloc.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ static size_t zend_shared_alloc_get_largest_free_block(void)
284284
void *zend_shared_alloc(size_t size)
285285
{
286286
int i;
287-
unsigned int block_size = size + sizeof(zend_shared_memory_block_header);
287+
unsigned int block_size = ZEND_ALIGNED_SIZE(size);
288288
TSRMLS_FETCH();
289289

290290
#if 1
@@ -298,19 +298,11 @@ void *zend_shared_alloc(size_t size)
298298
}
299299
for (i = 0; i < ZSMMG(shared_segments_count); i++) {
300300
if (ZSMMG(shared_segments)[i]->size - ZSMMG(shared_segments)[i]->pos >= block_size) { /* found a valid block */
301-
zend_shared_memory_block_header *p = (zend_shared_memory_block_header *) (((char *) ZSMMG(shared_segments)[i]->p) + ZSMMG(shared_segments)[i]->pos);
302-
int remainder = block_size % PLATFORM_ALIGNMENT;
303-
void *retval;
301+
void *retval = (void *) (((char *) ZSMMG(shared_segments)[i]->p) + ZSMMG(shared_segments)[i]->pos);
304302

305-
if (remainder != 0) {
306-
size += PLATFORM_ALIGNMENT - remainder;
307-
block_size += PLATFORM_ALIGNMENT - remainder;
308-
}
309303
ZSMMG(shared_segments)[i]->pos += block_size;
310304
ZSMMG(shared_free) -= block_size;
311-
p->size = size;
312-
retval = ((char *) p) + sizeof(zend_shared_memory_block_header);
313-
memset(retval, 0, size);
305+
memset(retval, 0, block_size);
314306
return retval;
315307
}
316308
}

ext/opcache/zend_shared_alloc.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,6 @@ typedef struct _handler_entry {
8989
zend_shared_memory_handlers *handler;
9090
} zend_shared_memory_handler_entry;
9191

92-
typedef struct _zend_shared_memory_block_header {
93-
int size;
94-
} zend_shared_memory_block_header;
95-
9692
typedef struct _zend_shared_memory_state {
9793
int *positions; /* current positions for each segment */
9894
int shared_free; /* amount of free shared memory */

0 commit comments

Comments
 (0)