Changeset 1883e8d in git


Ignore:
Timestamp:
2012-08-09T09:04:02Z (7 years ago)
Author:
Xuefer <xuefer@…>
Branches:
3.0, 3.1, 3.2, master, trunk
Children:
97ff55b
Parents:
068a669
Message:

refactor: s/mem/allocator/

git-svn-id: svn://svn.lighttpd.net/xcache/trunk@1135 c26eb9a1-5813-0410-bd6c-c2e55f420ca7

Files:
2 added
2 deleted
10 edited

Legend:

Unmodified
Added
Removed
  • Makefile.frag.deps

    rfde376c r1883e8d  
    1 $(XCACHE_INCLUDES_I) $(builddir)/includes.lo: $(srcdir)/xcache.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_mem.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_lock.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/mod_cacher/xc_cache.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_utils.h $(srcdir)/xcache/xc_compatibility.h
     1$(XCACHE_INCLUDES_I) $(builddir)/includes.lo: $(srcdir)/xcache.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_lock.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/mod_cacher/xc_cache.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_utils.h $(srcdir)/xcache/xc_compatibility.h
    22$(builddir)/mod_assembler/xc_assembler.lo:
    3 $(builddir)/mod_cacher/xc_cacher.lo: $(srcdir)/mod_cacher/xc_cacher.h $(srcdir)/mod_cacher/xc_cache.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_mem.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_lock.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_compatibility.h $(XCACHE_PROC_H) $(srcdir)/xcache.h $(srcdir)/mod_cacher/xc_cache.h $(srcdir)/xcache_globals.h $(srcdir)/util/xc_stack.h $(srcdir)/xcache/xc_extension.h $(srcdir)/util/xc_stack.h $(srcdir)/xcache/xc_ini.h $(srcdir)/xcache/xc_utils.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_sandbox.h $(srcdir)/util/xc_trace.h $(srcdir)/util/xc_vector.h $(srcdir)/util/xc_align.h
    4 $(builddir)/mod_coverager/xc_coverager.lo: $(srcdir)/mod_coverager/xc_coverager.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_mem.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_lock.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_extension.h $(srcdir)/util/xc_stack.h $(srcdir)/xcache/xc_ini.h $(srcdir)/xcache/xc_utils.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/util/xc_trace.h $(srcdir)/xcache_globals.h $(srcdir)/util/xc_stack.h
     3$(builddir)/mod_cacher/xc_cacher.lo: $(srcdir)/mod_cacher/xc_cacher.h $(srcdir)/mod_cacher/xc_cache.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_lock.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_compatibility.h $(XCACHE_PROC_H) $(srcdir)/xcache.h $(srcdir)/mod_cacher/xc_cache.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_allocator.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache_globals.h $(srcdir)/util/xc_stack.h $(srcdir)/xcache/xc_extension.h $(srcdir)/util/xc_stack.h $(srcdir)/xcache/xc_ini.h $(srcdir)/xcache/xc_utils.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_sandbox.h $(srcdir)/util/xc_trace.h $(srcdir)/util/xc_vector.h $(srcdir)/util/xc_align.h
     4$(builddir)/mod_coverager/xc_coverager.lo: $(srcdir)/mod_coverager/xc_coverager.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_lock.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_extension.h $(srcdir)/util/xc_stack.h $(srcdir)/xcache/xc_ini.h $(srcdir)/xcache/xc_utils.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/util/xc_trace.h $(srcdir)/xcache_globals.h $(srcdir)/util/xc_stack.h
    55$(builddir)/mod_decoder/xc_decoder.lo:
    6 $(builddir)/mod_disassembler/xc_disassembler.lo: $(srcdir)/mod_disassembler/xc_disassembler.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_mem.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_lock.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_ini.h $(srcdir)/xcache/xc_utils.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_sandbox.h $(srcdir)/xcache/xc_compatibility.h $(XCACHE_PROC_H) $(srcdir)/xcache.h $(srcdir)/mod_cacher/xc_cache.h
     6$(builddir)/mod_disassembler/xc_disassembler.lo: $(srcdir)/mod_disassembler/xc_disassembler.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_lock.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_ini.h $(srcdir)/xcache/xc_utils.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_sandbox.h $(srcdir)/xcache/xc_compatibility.h $(XCACHE_PROC_H) $(srcdir)/xcache.h $(srcdir)/mod_cacher/xc_cache.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_allocator.h $(srcdir)/xcache/xc_shm.h
    77$(builddir)/mod_encoder/xc_encoder.lo:
    8 $(builddir)/mod_optimizer/xc_optimizer.lo: $(srcdir)/mod_optimizer/xc_optimizer.h $(srcdir)/xcache/xc_extension.h $(srcdir)/util/xc_stack.h $(srcdir)/xcache/xc_ini.h $(srcdir)/xcache/xc_utils.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_mem.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_lock.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/util/xc_trace.h $(srcdir)/xcache_globals.h $(srcdir)/util/xc_stack.h
     8$(builddir)/mod_optimizer/xc_optimizer.lo: $(srcdir)/mod_optimizer/xc_optimizer.h $(srcdir)/xcache/xc_extension.h $(srcdir)/util/xc_stack.h $(srcdir)/xcache/xc_ini.h $(srcdir)/xcache/xc_utils.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_lock.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/util/xc_trace.h $(srcdir)/xcache_globals.h $(srcdir)/util/xc_stack.h
    99$(builddir)/util/xc_stack.lo: $(srcdir)/util/xc_trace.h $(srcdir)/util/xc_stack.h
    1010$(builddir)/util/xc_trace.lo: $(srcdir)/util/xc_trace.h
    11 $(builddir)/xcache.lo: $(srcdir)/xcache.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_mem.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_lock.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache_globals.h $(srcdir)/util/xc_stack.h $(srcdir)/xcache/xc_extension.h $(srcdir)/util/xc_stack.h $(srcdir)/xcache/xc_ini.h $(srcdir)/xcache/xc_const_string.h $(srcdir)/xcache/xc_opcode_spec.h $(srcdir)/xcache/xc_utils.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/util/xc_foreachcoresig.h
     11$(builddir)/xcache.lo: $(srcdir)/xcache.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_lock.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache_globals.h $(srcdir)/util/xc_stack.h $(srcdir)/xcache/xc_extension.h $(srcdir)/util/xc_stack.h $(srcdir)/xcache/xc_ini.h $(srcdir)/xcache/xc_const_string.h $(srcdir)/xcache/xc_opcode_spec.h $(srcdir)/xcache/xc_utils.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/util/xc_foreachcoresig.h
     12$(builddir)/xcache/xc_allocator_bestfit.lo: $(srcdir)/xcache/xc_allocator.h $(srcdir)/xcache/xc_shm.h $(srcdir)/util/xc_align.h $(srcdir)/util/xc_trace.h
     13$(builddir)/xcache/xc_allocator.lo: $(srcdir)/xcache/xc_allocator.h $(srcdir)/xcache/xc_shm.h
    1214$(builddir)/xcache/xc_compatibility.lo: $(srcdir)/xcache/xc_compatibility.h
    13 $(builddir)/xcache/xc_const_string.lo: $(srcdir)/xcache.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_mem.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_lock.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_const_string.h $(srcdir)/xcache/xc_const_string_opcodes_php5.4.h
    14 $(builddir)/xcache/xc_extension.lo: $(srcdir)/xcache/xc_extension.h $(srcdir)/util/xc_stack.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_mem.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_lock.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/util/xc_trace.h
     15$(builddir)/xcache/xc_const_string.lo: $(srcdir)/xcache.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_lock.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_const_string.h $(srcdir)/xcache/xc_const_string_opcodes_php5.4.h
     16$(builddir)/xcache/xc_extension.lo: $(srcdir)/xcache/xc_extension.h $(srcdir)/util/xc_stack.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_lock.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/util/xc_trace.h
    1517$(builddir)/xcache/xc_ini.lo: $(srcdir)/xcache/xc_ini.h
    16 $(builddir)/xcache/xc_lock.lo: $(srcdir)/xcache/xc_lock.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_mem.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_lock.h $(srcdir)/xcache/xc_compatibility.h
    17 $(builddir)/xcache/xc_malloc.lo: $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_mem.h $(srcdir)/xcache/xc_utils.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_lock.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/util/xc_align.h
    18 $(builddir)/xcache/xc_mem.lo: $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_mem.h $(srcdir)/util/xc_align.h $(srcdir)/util/xc_trace.h
    19 $(builddir)/xcache/xc_opcode_spec.lo: $(srcdir)/xcache.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_mem.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_lock.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_opcode_spec.h $(srcdir)/xcache/xc_const_string.h $(srcdir)/xcache/xc_opcode_spec_def.h
    20 $(builddir)/xcache/xc_processor.lo: $(XCACHE_PROC_C) $(srcdir)/xcache.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_mem.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_lock.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/mod_cacher/xc_cache.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/util/xc_align.h $(srcdir)/xcache/xc_const_string.h $(srcdir)/xcache/xc_utils.h $(srcdir)/xcache/xc_compatibility.h $(XCACHE_PROC_H) $(srcdir)/xcache_globals.h $(srcdir)/util/xc_stack.h
    21 $(builddir)/xcache/xc_sandbox.lo: $(srcdir)/xcache.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_mem.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_lock.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_sandbox.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_utils.h $(srcdir)/xcache_globals.h $(srcdir)/util/xc_stack.h
    22 $(builddir)/xcache/xc_shm.lo: $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_mem.h
    23 $(builddir)/xcache/xc_shm_mmap.lo: $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_mem.h $(srcdir)/xcache/xc_utils.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_lock.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_compatibility.h
    24 $(builddir)/xcache/xc_utils.lo: $(srcdir)/xcache.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_mem.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_lock.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache_globals.h $(srcdir)/util/xc_stack.h $(srcdir)/xcache/xc_utils.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_opcode_spec.h $(srcdir)/util/xc_trace.h
     18$(builddir)/xcache/xc_lock.lo: $(srcdir)/xcache/xc_lock.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_lock.h $(srcdir)/xcache/xc_compatibility.h
     19$(builddir)/xcache/xc_malloc.lo: $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_allocator.h $(srcdir)/xcache/xc_utils.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_lock.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/util/xc_align.h
     20$(builddir)/xcache/xc_opcode_spec.lo: $(srcdir)/xcache.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_lock.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_opcode_spec.h $(srcdir)/xcache/xc_const_string.h $(srcdir)/xcache/xc_opcode_spec_def.h
     21$(builddir)/xcache/xc_processor.lo: $(XCACHE_PROC_C) $(srcdir)/xcache.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_lock.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/mod_cacher/xc_cache.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_allocator.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_const_string.h $(srcdir)/xcache/xc_utils.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/util/xc_align.h $(XCACHE_PROC_H) $(srcdir)/xcache_globals.h $(srcdir)/util/xc_stack.h
     22$(builddir)/xcache/xc_sandbox.lo: $(srcdir)/xcache.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_lock.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_sandbox.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_utils.h $(srcdir)/xcache_globals.h $(srcdir)/util/xc_stack.h
     23$(builddir)/xcache/xc_shm.lo: $(srcdir)/xcache/xc_shm.h
     24$(builddir)/xcache/xc_shm_mmap.lo: $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_utils.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_lock.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_compatibility.h
     25$(builddir)/xcache/xc_utils.lo: $(srcdir)/xcache.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_lock.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache_globals.h $(srcdir)/util/xc_stack.h $(srcdir)/xcache/xc_utils.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_opcode_spec.h $(srcdir)/util/xc_trace.h
  • config.m4

    r79aa9f1 r1883e8d  
    3232done
    3333  for i in \
     34xc_allocator.c \
     35xc_allocator_bestfit.c \
    3436xc_compatibility.c \
    3537xc_const_string.c \
     
    3739xc_ini.c \
    3840xc_lock.c \
    39 xc_mem.c \
    4041xc_opcode_spec.c \
    4142xc_processor.c \
  • config.w32

    r2782394 r1883e8d  
    1919
    2020    ADD_SOURCES(configure_module_dirname + "/xcache", " \
     21xc_allocator.c \
     22xc_allocator_bestfit.c \
    2123xc_compatibility.c \
    2224xc_const_string.c \
     
    2426xc_ini.c \
    2527xc_lock.c \
    26 xc_mem.c \
    2728xc_opcode_spec.c \
    2829xc_processor.c \
  • devel/test.mak

    r4e78a9d r1883e8d  
    11#! /usr/bin/make -f
    22
    3 EXES=mem_test
    4 OBJS=mem.o
     3EXES=allocator_test
     4OBJS=allocator.o
    55CC=gcc
    6 CFLAGS=-g -O0 -I. -D TEST -Wall
     6CFLAGS=-g -O0 -I. -D TEST -D HAVE_XCACHE_TEST -Wall
    77TEST=valgrind
    88
    9 all: mem
     9all: allocator
    1010
    11 mem_test: xcache/xc_mem.c xcache/xc_mem.h util/xc_trace.c util/xc_trace.h
    12     $(CC) $(CFLAGS) -o mem_test xcache/xc_mem.c util/xc_trace.c
     11allocator_test: xcache/xc_allocator.h xcache/xc_allocator.c xcache/xc_malloc.c xcache/xc_allocator_bestfit.c util/xc_trace.c util/xc_trace.h
     12    $(CC) $(CFLAGS) -o allocator_test xcache/xc_allocator.c xcache/xc_malloc.c xcache/xc_allocator_bestfit.c util/xc_trace.c
    1313   
    14 mem: mem_test
    15     $(TEST) ./mem_test
     14allocator: allocator_test
     15    $(TEST) ./allocator_test
    1616
    1717clean:
  • mod_cacher/xc_cacher.c

    r6b2ab88 r1883e8d  
    100100    struct _xc_lock_t  *lck;
    101101    struct _xc_shm_t   *shm; /* which shm contains us */
    102     struct _xc_mem_t   *mem; /* which mem contains us */
     102    xc_allocator_t *allocator;
    103103
    104104    xc_hash_t  *hentry; /* hash settings to entry */
     
    125125static zend_ulong xc_var_gc_interval = 0;
    126126
     127static char *xc_php_allocator = NULL;
     128static char *xc_var_allocator = NULL;
     129
    127130/* total size */
    128131static zend_ulong xc_php_size  = 0;
     
    163166    php->hits     = 0;
    164167    php->refcount = 0;
    165     stored_php = xc_processor_store_xc_entry_data_php_t(cache->shm, cache->mem, php TSRMLS_CC);
     168    stored_php = xc_processor_store_xc_entry_data_php_t(cache->shm, cache->allocator, php TSRMLS_CC);
    166169    if (stored_php) {
    167170        xc_php_add_unlocked(cache->cached, stored_php);
     
    188191static void xc_php_free_unlocked(xc_cache_t *cache, xc_entry_data_php_t *php) /* {{{ */
    189192{
    190     cache->mem->handlers->free(cache->mem, (xc_entry_data_php_t *)php);
     193    cache->allocator->vtable->free(cache->allocator, (xc_entry_data_php_t *)php);
    191194}
    192195/* }}} */
     
    310313    entry->atime = XG(request_time);
    311314    stored_entry = type == XC_TYPE_PHP
    312         ? (xc_entry_t *) xc_processor_store_xc_entry_php_t(cache->shm, cache->mem, (xc_entry_php_t *) entry TSRMLS_CC)
    313         : (xc_entry_t *) xc_processor_store_xc_entry_var_t(cache->shm, cache->mem, (xc_entry_var_t *) entry TSRMLS_CC);
     315        ? (xc_entry_t *) xc_processor_store_xc_entry_php_t(cache->shm, cache->allocator, (xc_entry_php_t *) entry TSRMLS_CC)
     316        : (xc_entry_t *) xc_processor_store_xc_entry_var_t(cache->shm, cache->allocator, (xc_entry_var_t *) entry TSRMLS_CC);
    314317    if (stored_entry) {
    315318        xc_entry_add_unlocked(cache->cached, entryslotid, stored_entry);
     
    338341        xc_php_release_unlocked(cache, ((xc_entry_php_t *) entry)->php);
    339342    }
    340     cache->mem->handlers->free(cache->mem, (xc_entry_t *)entry);
     343    cache->allocator->vtable->free(cache->allocator, (xc_entry_t *)entry);
    341344}
    342345/* }}} */
     
    604607    zval *blocks, *hits;
    605608    size_t i;
    606     const xc_block_t *b;
     609    const xc_allocator_block_t *b;
    607610#ifndef NDEBUG
    608611    xc_memsize_t avail = 0;
    609612#endif
    610     const xc_mem_t *mem = cache->mem;
    611     const xc_mem_handlers_t *handlers = mem->handlers;
     613    const xc_allocator_t *allocator = cache->allocator;
     614    const xc_allocator_vtable_t *vtable = allocator->vtable;
    612615    zend_ulong interval;
    613616    const xc_cached_t *cached = cache->cached;
     
    657660    array_init(blocks);
    658661
    659     add_assoc_long_ex(return_value, ZEND_STRS("size"),  handlers->size(mem));
    660     add_assoc_long_ex(return_value, ZEND_STRS("avail"), handlers->avail(mem));
     662    add_assoc_long_ex(return_value, ZEND_STRS("size"),  vtable->size(allocator));
     663    add_assoc_long_ex(return_value, ZEND_STRS("avail"), vtable->avail(allocator));
    661664    add_assoc_bool_ex(return_value, ZEND_STRS("can_readonly"), xc_readonly_protection);
    662665
    663     for (b = handlers->freeblock_first(mem); b; b = handlers->freeblock_next(b)) {
     666    for (b = vtable->freeblock_first(allocator); b; b = vtable->freeblock_next(b)) {
    664667        zval *bi;
    665668
     
    667670        array_init(bi);
    668671
    669         add_assoc_long_ex(bi, ZEND_STRS("size"),   handlers->block_size(b));
    670         add_assoc_long_ex(bi, ZEND_STRS("offset"), handlers->block_offset(mem, b));
     672        add_assoc_long_ex(bi, ZEND_STRS("size"),   vtable->block_size(b));
     673        add_assoc_long_ex(bi, ZEND_STRS("offset"), vtable->block_offset(allocator, b));
    671674        add_next_index_zval(blocks, bi);
    672675#ifndef NDEBUG
    673         avail += handlers->block_size(b);
     676        avail += vtable->block_size(b);
    674677#endif
    675678    }
    676679    add_assoc_zval_ex(return_value, ZEND_STRS("free_blocks"), blocks);
    677680#ifndef NDEBUG
    678     assert(avail == handlers->avail(mem));
     681    assert(avail == vtable->avail(allocator));
    679682#endif
    680683}
     
    23112314            /* do NOT touch cached data */
    23122315            shm = cache->shm;
    2313             cache->shm->handlers->memdestroy(cache->mem);
     2316            cache->shm->handlers->memdestroy(cache->allocator);
    23142317        }
    23152318    }
     
    23182321}
    23192322/* }}} */
    2320 static xc_cache_t *xc_cache_init(xc_shm_t *shm, xc_hash_t *hcache, xc_hash_t *hentry, xc_hash_t *hphp, xc_shmsize_t shmsize) /* {{{ */
     2323static xc_cache_t *xc_cache_init(xc_shm_t *shm, const char *allocator_name, xc_hash_t *hcache, xc_hash_t *hentry, xc_hash_t *hphp, xc_shmsize_t shmsize) /* {{{ */
    23212324{
    23222325    xc_cache_t *caches = NULL;
    2323     xc_mem_t *mem;
     2326    xc_allocator_t *allocator;
    23242327    time_t now = time(NULL);
    23252328    size_t i;
     
    23432346    for (i = 0; i < hcache->size; i ++) {
    23442347        xc_cache_t *cache = &caches[i];
    2345         CHECK(mem                     = shm->handlers->meminit(shm, memsize), "Failed init memory allocator");
    2346         CHECK(cache->cached           = mem->handlers->calloc(mem, 1, sizeof(xc_cached_t)), "cache OOM");
    2347         CHECK(cache->cached->entries  = mem->handlers->calloc(mem, hentry->size, sizeof(xc_entry_t*)), "entries OOM");
     2348        CHECK(allocator = shm->handlers->meminit(shm, memsize), "Failed init shm");
     2349        if (!(allocator->vtable = xc_allocator_find(allocator_name))) {
     2350            zend_error(E_ERROR, "Allocator %s not found", allocator_name);
     2351            goto err;
     2352        }
     2353        CHECK(allocator->vtable->init(shm, allocator, memsize), "Failed init allocator");
     2354        CHECK(cache->cached           = allocator->vtable->calloc(allocator, 1, sizeof(xc_cached_t)), "cache OOM");
     2355        CHECK(cache->cached->entries  = allocator->vtable->calloc(allocator, hentry->size, sizeof(xc_entry_t*)), "entries OOM");
    23482356        if (hphp) {
    2349             CHECK(cache->cached->phps = mem->handlers->calloc(mem, hphp->size, sizeof(xc_entry_data_php_t*)), "phps OOM");
     2357            CHECK(cache->cached->phps = allocator->vtable->calloc(allocator, hphp->size, sizeof(xc_entry_data_php_t*)), "phps OOM");
    23502358        }
    23512359        CHECK(cache->lck              = xc_lock_init(NULL), "can't create lock");
     
    23552363        cache->hphp    = hphp;
    23562364        cache->shm     = shm;
    2357         cache->mem     = mem;
     2365        cache->allocator = allocator;
    23582366        cache->cacheid = i;
    23592367        cache->cached->last_gc_deletes = now;
     
    24132421
    24142422        if (xc_php_size) {
    2415             CHECK(xc_php_caches = xc_cache_init(shm, &xc_php_hcache, &xc_php_hentry, &xc_php_hentry, xc_php_size), "failed init opcode cache");
     2423            CHECK(xc_php_caches = xc_cache_init(shm, xc_php_allocator, &xc_php_hcache, &xc_php_hentry, &xc_php_hentry, xc_php_size), "failed init opcode cache");
    24162424        }
    24172425
    24182426        if (xc_var_size) {
    2419             CHECK(xc_var_caches = xc_cache_init(shm, &xc_var_hcache, &xc_var_hentry, NULL, xc_var_size), "failed init variable cache");
     2427            CHECK(xc_var_caches = xc_cache_init(shm, xc_var_allocator, &xc_var_hcache, &xc_var_hentry, NULL, xc_var_size), "failed init variable cache");
    24202428        }
    24212429    }
     
    31843192    PHP_INI_ENTRY1     ("xcache.count",                  "1", PHP_INI_SYSTEM, xcache_OnUpdateDummy,    NULL)
    31853193    PHP_INI_ENTRY1     ("xcache.slots",                 "8K", PHP_INI_SYSTEM, xcache_OnUpdateDummy,    NULL)
     3194    PHP_INI_ENTRY1     ("xcache.allocator",        "bestfit", PHP_INI_SYSTEM, xcache_OnUpdateString,   &xc_php_allocator)
    31863195    PHP_INI_ENTRY1     ("xcache.ttl",                    "0", PHP_INI_SYSTEM, xcache_OnUpdateULong,    &xc_php_ttl)
    31873196    PHP_INI_ENTRY1     ("xcache.gc_interval",            "0", PHP_INI_SYSTEM, xcache_OnUpdateULong,    &xc_php_gc_interval)
     
    31943203    PHP_INI_ENTRY1     ("xcache.var_maxttl",             "0", PHP_INI_SYSTEM, xcache_OnUpdateULong,    &xc_var_maxttl)
    31953204    PHP_INI_ENTRY1     ("xcache.var_gc_interval",      "120", PHP_INI_SYSTEM, xcache_OnUpdateULong,    &xc_var_gc_interval)
     3205    PHP_INI_ENTRY1     ("xcache.var_allocator",    "bestfit", PHP_INI_SYSTEM, xcache_OnUpdateString,   &xc_var_allocator)
    31963206    STD_PHP_INI_ENTRY  ("xcache.var_ttl",                "0", PHP_INI_ALL,    OnUpdateLong, var_ttl,   zend_xcache_globals, xcache_globals)
    31973207PHP_INI_END()
     
    33603370        pefree(xc_shm_scheme, 1);
    33613371        xc_shm_scheme = NULL;
     3372    }
     3373    if (xc_php_allocator) {
     3374        pefree(xc_php_allocator, 1);
     3375        xc_php_allocator = NULL;
     3376    }
     3377    if (xc_var_allocator) {
     3378        pefree(xc_var_allocator, 1);
     3379        xc_var_allocator = NULL;
    33623380    }
    33633381
  • processor/head.m4

    r6b2ab88 r1883e8d  
    1414/* export: #include "mod_cacher/xc_cache.h" :export */
    1515#include "mod_cacher/xc_cache.h"
    16 #include "util/xc_align.h"
     16/* export: #include "xcache/xc_shm.h" :export */
     17#include "xcache/xc_shm.h"
     18/* export: #include "xcache/xc_allocator.h" :export */
     19#include "xcache/xc_allocator.h"
    1720#include "xcache/xc_const_string.h"
    1821#include "xcache/xc_utils.h"
     22#include "util/xc_align.h"
    1923#include "xc_processor.h"
    2024#include "xcache_globals.h"
     
    9599    const xc_entry_data_php_t *php_dst;
    96100    xc_shm_t                  *shm;
    97     xc_mem_t                  *mem;
     101    xc_allocator_t            *allocator;
    98102    const zend_class_entry *cache_ce;
    99103    zend_uint cache_class_index;
     
    395399dnl ================ export API
    396400define(`DEFINE_STORE_API', `
    397 /* export: $1 *xc_processor_store_$1(xc_shm_t *shm, xc_mem_t *mem, $1 *src TSRMLS_DC); :export {{{ */
    398 $1 *xc_processor_store_$1(xc_shm_t *shm, xc_mem_t *mem, $1 *src TSRMLS_DC) {
     401/* export: $1 *xc_processor_store_$1(xc_shm_t *shm, xc_allocator_t *allocator, $1 *src TSRMLS_DC); :export {{{ */
     402$1 *xc_processor_store_$1(xc_shm_t *shm, xc_allocator_t *allocator, $1 *src TSRMLS_DC) {
    399403    $1 *dst;
    400404    xc_processor_t processor;
     
    403407    processor.reference = 1;
    404408    processor.shm = shm;
    405     processor.mem = mem;
     409    processor.allocator = allocator;
    406410
    407411    IFAUTOCHECK(`xc_stack_init(&processor.allocsizes);')
     
    440444        }
    441445
    442         /* mem :) */
    443         processor.p = (char *) processor.mem->handlers->malloc(processor.mem, processor.size);
     446        /* allocator :) */
     447        processor.p = (char *) processor.allocator->vtable->malloc(processor.allocator, processor.size);
    444448        if (processor.p == NULL) {
    445449            dst = NULL;
  • xcache/xc_malloc.c

    r5876ee7 r1883e8d  
    11#define XC_SHM_IMPL _xc_malloc_shm_t
    2 #define XC_MEM_IMPL _xc_malloc_mem_t
     2#define _xc_allocator_t _xc_allocator_malloc_t
    33#include <stdlib.h>
    44#include <stdio.h>
     
    99#endif
    1010#include "xc_shm.h"
    11 #include "php.h"
    12 #include "xc_utils.h"
     11#include "xc_allocator.h"
     12#ifndef TEST
     13#include "xcache.h"
     14#endif
    1315#include "util/xc_align.h"
    1416
    15 struct _xc_malloc_mem_t {
    16     const xc_mem_handlers_t *handlers;
    17     xc_shm_t                *shm;
     17struct _xc_allocator_malloc_t {
     18    const xc_allocator_vtable_t *vtable;
     19    xc_shm_t *shm;
    1820    xc_memsize_t size;
    1921    xc_memsize_t avail;       /* total free */
     
    2527    xc_shmsize_t       size;
    2628    xc_shmsize_t       memoffset;
     29#ifndef TEST
    2730    HashTable blocks;
     31#endif
    2832};
    2933/* }}} */
    3034
    31 #define CHECK(x, e) do { if ((x) == NULL) { zend_error(E_ERROR, "XCache: " e); goto err; } } while (0)
    32 
    33 static void *xc_add_to_blocks(xc_mem_t *mem, void *p, size_t size) /* {{{ */
     35#ifndef TEST
     36#   define CHECK(x, e) do { if ((x) == NULL) { zend_error(E_ERROR, "XCache: " e); goto err; } } while (0)
     37#else
     38#   define CHECK(x, e) do { if ((x) == NULL) { fprintf(stderr, "%s\n", "XCache: " e); goto err; } } while (0)
     39#endif
     40
     41static void *xc_add_to_blocks(xc_allocator_t *allocator, void *p, size_t size) /* {{{ */
    3442{
    3543    if (p) {
    36         zend_hash_add(&mem->shm->blocks, (void *) &p, sizeof(p), (void *) &size, sizeof(size), NULL);
     44#ifdef TEST
     45        allocator->avail -= size;
     46#else
     47        zend_hash_add(&allocator->shm->blocks, (void *) &p, sizeof(p), (void *) &size, sizeof(size), NULL);
     48#endif
    3749    }
    3850    return p;
    3951}
    4052/* }}} */
    41 static void xc_del_from_blocks(xc_mem_t *mem, void *p) /* {{{ */
    42 {
    43     zend_hash_del(&mem->shm->blocks, (void *) &p, sizeof(p));
    44 }
    45 /* }}} */
    46 
    47 static XC_MEM_MALLOC(xc_malloc_malloc) /* {{{ */
    48 {
    49     return xc_add_to_blocks(mem, malloc(size), size);
    50 }
    51 /* }}} */
    52 static XC_MEM_FREE(xc_malloc_free) /* {{{ return block size freed */
    53 {
    54     xc_del_from_blocks(mem, (void *) p);
     53static void xc_del_from_blocks(xc_allocator_t *allocator, void *p) /* {{{ */
     54{
     55#ifdef TEST
     56    /* TODO: allocator->avail += size; */
     57#else
     58    zend_hash_del(&allocator->shm->blocks, (void *) &p, sizeof(p));
     59#endif
     60}
     61/* }}} */
     62
     63static XC_ALLOCATOR_MALLOC(xc_allocator_malloc_malloc) /* {{{ */
     64{
     65    return xc_add_to_blocks(allocator, malloc(size), size);
     66}
     67/* }}} */
     68static XC_ALLOCATOR_FREE(xc_allocator_malloc_free) /* {{{ return block size freed */
     69{
     70    xc_del_from_blocks(allocator, (void *) p);
    5571    free((void *) p);
    5672    return 0;
    5773}
    5874/* }}} */
    59 static XC_MEM_CALLOC(xc_malloc_calloc) /* {{{ */
    60 {
    61     return xc_add_to_blocks(mem, calloc(memb, size), size);
    62 }
    63 /* }}} */
    64 static XC_MEM_REALLOC(xc_malloc_realloc) /* {{{ */
    65 {
    66     return xc_add_to_blocks(mem, realloc((void *) p, size), size);
    67 }
    68 /* }}} */
    69 static XC_MEM_STRNDUP(xc_malloc_strndup) /* {{{ */
    70 {
    71     char *p = xc_add_to_blocks(mem, malloc(len), len);
    72     if (!p) {
    73         return NULL;
    74     }
    75     return memcpy(p, str, len);
    76 }
    77 /* }}} */
    78 static XC_MEM_STRDUP(xc_malloc_strdup) /* {{{ */
    79 {
    80     return xc_malloc_strndup(mem, str, strlen(str) + 1);
    81 }
    82 /* }}} */
    83 
    84 static XC_MEM_AVAIL(xc_malloc_avail) /* {{{ */
    85 {
    86     return mem->avail;
    87 }
    88 /* }}} */
    89 static XC_MEM_SIZE(xc_malloc_size) /* {{{ */
    90 {
    91     return mem->size;
    92 }
    93 /* }}} */
    94 
    95 static XC_MEM_FREEBLOCK_FIRST(xc_malloc_freeblock_first) /* {{{ */
     75static XC_ALLOCATOR_CALLOC(xc_allocator_malloc_calloc) /* {{{ */
     76{
     77    return xc_add_to_blocks(allocator, calloc(memb, size), size);
     78}
     79/* }}} */
     80static XC_ALLOCATOR_REALLOC(xc_allocator_malloc_realloc) /* {{{ */
     81{
     82    return xc_add_to_blocks(allocator, realloc((void *) p, size), size);
     83}
     84/* }}} */
     85
     86static XC_ALLOCATOR_AVAIL(xc_allocator_malloc_avail) /* {{{ */
     87{
     88    return allocator->avail;
     89}
     90/* }}} */
     91static XC_ALLOCATOR_SIZE(xc_allocator_malloc_size) /* {{{ */
     92{
     93    return allocator->size;
     94}
     95/* }}} */
     96
     97static XC_ALLOCATOR_FREEBLOCK_FIRST(xc_allocator_malloc_freeblock_first) /* {{{ */
    9698{
    9799    return (void *) -1;
    98100}
    99101/* }}} */
    100 XC_MEM_FREEBLOCK_NEXT(xc_malloc_freeblock_next) /* {{{ */
     102static XC_ALLOCATOR_FREEBLOCK_NEXT(xc_allocator_malloc_freeblock_next) /* {{{ */
    101103{
    102104    return NULL;
    103105}
    104106/* }}} */
    105 XC_MEM_BLOCK_SIZE(xc_malloc_block_size) /* {{{ */
    106 {
    107     return 0;
    108 }
    109 /* }}} */
    110 XC_MEM_BLOCK_OFFSET(xc_malloc_block_offset) /* {{{ */
    111 {
    112     return 0;
    113 }
    114 /* }}} */
    115 
    116 static XC_MEM_INIT(xc_mem_malloc_init) /* {{{ */
    117 {
    118 #define MINSIZE (ALIGN(sizeof(xc_mem_t)))
     107static XC_ALLOCATOR_BLOCK_SIZE(xc_allocator_malloc_block_size) /* {{{ */
     108{
     109    return 0;
     110}
     111/* }}} */
     112static XC_ALLOCATOR_BLOCK_OFFSET(xc_allocator_malloc_block_offset) /* {{{ */
     113{
     114    return 0;
     115}
     116/* }}} */
     117
     118static XC_ALLOCATOR_INIT(xc_allocator_malloc_init) /* {{{ */
     119{
     120#define MINSIZE (ALIGN(sizeof(xc_allocator_t)))
    119121    /* requires at least the header and 1 tail block */
    120122    if (size < MINSIZE) {
    121         fprintf(stderr, "xc_mem_malloc_init requires %lu bytes at least\n", (unsigned long) MINSIZE);
     123        fprintf(stderr, "xc_allocator_malloc_init requires %lu bytes at least\n", (unsigned long) MINSIZE);
    122124        return NULL;
    123125    }
    124     mem->shm = shm;
    125     mem->size = size;
    126     mem->avail = size - MINSIZE;
     126    allocator->shm = shm;
     127    allocator->size = size;
     128    allocator->avail = size - MINSIZE;
    127129#undef MINSIZE
    128130
    129     return mem;
    130 }
    131 /* }}} */
    132 static XC_MEM_DESTROY(xc_mem_malloc_destroy) /* {{{ */
     131    return allocator;
     132}
     133/* }}} */
     134static XC_ALLOCATOR_DESTROY(xc_allocator_malloc_destroy) /* {{{ */
    133135{
    134136}
     
    142144static XC_SHM_IS_READWRITE(xc_malloc_is_readwrite) /* {{{ */
    143145{
     146#ifndef TEST
    144147    HashPosition pos;
    145148    size_t *psize;
     
    154157        zend_hash_move_forward_ex(&shm->blocks, &pos);
    155158    }
     159#endif
    156160
    157161    return 0;
     
    176180static XC_SHM_DESTROY(xc_malloc_destroy) /* {{{ */
    177181{
     182#ifndef TEST
    178183    zend_hash_destroy(&shm->blocks);
     184#endif
    179185    free(shm);
    180186    return;
     
    187193    shm->size = size;
    188194
     195#ifndef TEST
    189196    zend_hash_init(&shm->blocks, 64, NULL, NULL, 1);
     197#endif
    190198    return shm;
    191199err:
     
    196204static XC_SHM_MEMINIT(xc_malloc_meminit) /* {{{ */
    197205{
    198     xc_mem_t *mem;
     206    void *mem;
    199207    if (shm->memoffset + size > shm->size) {
     208#ifndef TEST
    200209        zend_error(E_ERROR, "XCache: internal error at %s#%d", __FILE__, __LINE__);
     210#endif
    201211        return NULL;
    202212    }
    203213    shm->memoffset += size;
    204     CHECK(mem = calloc(1, sizeof(xc_mem_t)), "mem OOM");
    205     mem->handlers = shm->handlers->memhandlers;
    206     mem->handlers->init(shm, mem, size);
     214    CHECK(mem = calloc(1, size), "mem OOM");
    207215    return mem;
    208216err:
     
    212220static XC_SHM_MEMDESTROY(xc_malloc_memdestroy) /* {{{ */
    213221{
    214     mem->handlers->destroy(mem);
    215222    free(mem);
    216223}
    217224/* }}} */
    218225
    219 #define xc_malloc_destroy xc_mem_malloc_destroy
    220 #define xc_malloc_init xc_mem_malloc_init
    221 static xc_mem_handlers_t xc_mem_malloc_handlers = XC_MEM_HANDLERS(malloc);
    222 #undef xc_malloc_init
    223 #undef xc_malloc_destroy
     226static xc_allocator_vtable_t xc_allocator_malloc_vtable = XC_ALLOCATOR_VTABLE(allocator_malloc);
    224227static xc_shm_handlers_t xc_shm_malloc_handlers = XC_SHM_HANDLERS(malloc);
     228void xc_allocator_malloc_register() /* {{{ */
     229{
     230    if (xc_allocator_register("malloc", &xc_allocator_malloc_vtable) == 0) {
     231#ifndef TEST
     232        zend_error(E_ERROR, "XCache: failed to register malloc mem_scheme");
     233#endif
     234    }
     235}
     236/* }}} */
     237
     238#ifndef TEST
    225239void xc_shm_malloc_register() /* {{{ */
    226240{
    227     if (xc_mem_scheme_register("malloc", &xc_mem_malloc_handlers) == 0) {
    228         zend_error(E_ERROR, "XCache: failed to register malloc mem_scheme");
    229     }
    230 
    231     CHECK(xc_shm_malloc_handlers.memhandlers = xc_mem_scheme_find("malloc"), "cannot find malloc handlers");
    232241    if (xc_shm_scheme_register("malloc", &xc_shm_malloc_handlers) == 0) {
    233242        zend_error(E_ERROR, "XCache: failed to register malloc shm_scheme");
    234243    }
    235 err:
    236     return;
    237 }
    238 /* }}} */
     244}
     245/* }}} */
     246#endif
  • xcache/xc_shm.c

    r070be8e r1883e8d  
    2323void xc_shm_init_modules() /* {{{ */
    2424{
    25     extern void xc_shm_mem_init();
     25    extern void xc_allocator_init();
    2626#ifdef HAVE_XCACHE_TEST
    2727    extern void xc_shm_malloc_register();
     
    3030
    3131    memset(xc_shm_schemes, 0, sizeof(xc_shm_schemes));
    32     xc_shm_mem_init();
     32    xc_allocator_init();
    3333#ifdef HAVE_XCACHE_TEST
    3434    xc_shm_malloc_register();
  • xcache/xc_shm.h

    r79aa9f1 r1883e8d  
    11#ifndef XC_SHM_H
    22#define XC_SHM_H
     3
     4#include <stdlib.h>
     5
    36typedef struct _xc_shm_handlers_t xc_shm_handlers_t;
    47
     
    1316typedef size_t xc_shmsize_t;
    1417
    15 #include "xc_mem.h"
    16 
    1718/* shm */
    1819#define XC_SHM_CAN_READONLY(func) int   func(xc_shm_t *shm)
     
    2526#define XC_SHM_DESTROY(func)      void func(xc_shm_t *shm)
    2627
    27 #define XC_SHM_MEMINIT(func)      xc_mem_t *func(xc_shm_t *shm, xc_memsize_t size)
    28 #define XC_SHM_MEMDESTROY(func)   void func(xc_mem_t *mem)
     28#define XC_SHM_MEMINIT(func)      void *func(xc_shm_t *shm, xc_shmsize_t size)
     29#define XC_SHM_MEMDESTROY(func)   void func(void *mem)
    2930
    3031#define XC_SHM_HANDLERS(name)    { \
    31     NULL                           \
    32     , xc_##name##_can_readonly     \
     32    xc_##name##_can_readonly       \
    3333    , xc_##name##_is_readwrite     \
    3434    , xc_##name##_is_readonly      \
     
    4444
    4545struct _xc_shm_handlers_t {
    46     const xc_mem_handlers_t *memhandlers;
    4746    XC_SHM_CAN_READONLY((*can_readonly));
    4847    XC_SHM_IS_READWRITE((*is_readwrite));
  • xcache/xc_shm_mmap.c

    r070be8e r1883e8d  
    295295static XC_SHM_MEMINIT(xc_mmap_meminit) /* {{{ */
    296296{
    297     xc_mem_t *mem;
     297    void *mem;
    298298    if (shm->memoffset + size > shm->size) {
    299299        zend_error(E_ERROR, "XCache: internal error at %s#%d", __FILE__, __LINE__);
    300300        return NULL;
    301301    }
    302     mem = (xc_mem_t *) PTR_ADD(shm->ptr, shm->memoffset);
     302    mem = PTR_ADD(shm->ptr, shm->memoffset);
    303303    shm->memoffset += size;
    304     mem->handlers = shm->handlers->memhandlers;
    305     mem->handlers->init(shm, mem, size);
    306304    return mem;
    307305}
     
    315313void xc_shm_mmap_register() /* {{{ */
    316314{
    317     CHECK(xc_shm_mmap_handlers.memhandlers = xc_mem_scheme_find("mem"), "cannot find mem handlers");
    318315    if (xc_shm_scheme_register("mmap", &xc_shm_mmap_handlers) == 0) {
    319316        zend_error(E_ERROR, "XCache: failed to register mmap shm_scheme");
    320317    }
    321 err:
    322318    return;
    323319}
Note: See TracChangeset for help on using the changeset viewer.