Browse Source

refactor: code clean up

git-svn-id: svn://svn.lighttpd.net/xcache/trunk@1129 c26eb9a1-5813-0410-bd6c-c2e55f420ca7
3.0
Xuefer 9 years ago
parent
commit
5876ee7fb9
  1. 3
      mod_cacher/xc_cacher.c
  2. 6
      xcache.c
  3. 12
      xcache/xc_malloc.c

3
mod_cacher/xc_cacher.c

@ -3312,9 +3312,6 @@ static PHP_MINIT_FUNCTION(xcache_cacher) /* {{{ */
xc_config_hash(&xc_var_hentry, "xcache.var_slots", "8K");
if (strcmp(sapi_module.name, "cli") == 0) {
if ((env = getenv("XCACHE_TEST")) != NULL) {
xc_test = atoi(env);
}
if (!xc_test) {
/* disable cache for cli except for testing */
xc_php_size = xc_var_size = 0;

6
xcache.c

@ -689,6 +689,12 @@ static PHP_MINIT_FUNCTION(xcache) /* {{{ */
xcache_init_crash_handler();
}
if (strcmp(sapi_module.name, "cli") == 0) {
if ((env = getenv("XCACHE_TEST")) != NULL) {
xc_test = atoi(env);
}
}
xc_init_constant(module_number TSRMLS_CC);
xc_shm_init_modules();

12
xcache/xc_malloc.c

@ -24,9 +24,7 @@ struct _xc_malloc_shm_t {
xc_shm_handlers_t *handlers;
xc_shmsize_t size;
xc_shmsize_t memoffset;
#ifdef HAVE_XCACHE_TEST
HashTable blocks;
#endif
};
/* }}} */
@ -34,19 +32,15 @@ struct _xc_malloc_shm_t {
static void *xc_add_to_blocks(xc_mem_t *mem, void *p, size_t size) /* {{{ */
{
#ifdef HAVE_XCACHE_TEST
if (p) {
zend_hash_add(&mem->shm->blocks, (void *) &p, sizeof(p), (void *) &size, sizeof(size), NULL);
}
#endif
return p;
}
/* }}} */
static void xc_del_from_blocks(xc_mem_t *mem, void *p) /* {{{ */
{
#ifdef HAVE_XCACHE_TEST
zend_hash_del(&mem->shm->blocks, (void *) &p, sizeof(p));
#endif
}
/* }}} */
@ -147,7 +141,6 @@ static XC_SHM_CAN_READONLY(xc_malloc_can_readonly) /* {{{ */
/* }}} */
static XC_SHM_IS_READWRITE(xc_malloc_is_readwrite) /* {{{ */
{
#ifdef HAVE_XCACHE_TEST
HashPosition pos;
size_t *psize;
char **ptr;
@ -160,7 +153,6 @@ static XC_SHM_IS_READWRITE(xc_malloc_is_readwrite) /* {{{ */
}
zend_hash_move_forward_ex(&shm->blocks, &pos);
}
#endif
return 0;
}
@ -183,9 +175,7 @@ static XC_SHM_TO_READONLY(xc_malloc_to_readonly) /* {{{ */
static XC_SHM_DESTROY(xc_malloc_destroy) /* {{{ */
{
#ifdef HAVE_XCACHE_TEST
zend_hash_destroy(&shm->blocks);
#endif
free(shm);
return;
}
@ -196,9 +186,7 @@ static XC_SHM_INIT(xc_malloc_init) /* {{{ */
CHECK(shm = calloc(1, sizeof(xc_shm_t)), "shm OOM");
shm->size = size;
#ifdef HAVE_XCACHE_TEST
zend_hash_init(&shm->blocks, 64, NULL, NULL, 1);
#endif
return shm;
err:
return NULL;

Loading…
Cancel
Save