Index: trunk/devel/run
===================================================================
--- trunk/devel/run	(revision 1061)
+++ trunk/devel/run	(revision 1062)
@@ -147,5 +147,8 @@
 
 LANG=C /usr/bin/make $MAKEOPTS "${MAKEARGS[@]}" 2>&1 \
-| sed -ur 's#Werror=implicit-function-declaration#We/rror=i/mplicit-function-declaration#' \
+| sed -ur \
+	-e 's#Werror=implicit-function-declaration#We/rror=i/mplicit-function-declaration#' \
+	-e 's#\./xc_processor\.h#'$PWD'/xc_processor.h#' \
+	-e 's#\./xc_processor\.c\.h#'$PWD'/xc_processor.c.h#' \
 | hi error implicit warn FAIL
 ret=${PIPESTATUS[0]}
Index: trunk/mod_cacher/xc_cache.h
===================================================================
--- trunk/mod_cacher/xc_cache.h	(revision 1061)
+++ trunk/mod_cacher/xc_cache.h	(revision 1062)
@@ -11,4 +11,5 @@
 typedef ulong xc_hash_value_t;
 typedef struct _xc_hash_t xc_hash_t;
+typedef struct _xc_cached_t xc_cached_t;
 typedef struct _xc_entry_t xc_entry_t;
 typedef struct _xc_entry_data_php_t xc_entry_data_php_t;
@@ -16,37 +17,16 @@
 struct _xc_lock_t;
 struct _xc_shm_t;
-/* {{{ xc_cache_t */
+/* {{{ xc_cache_t: only cache info, not in shm */
 typedef struct {
 	int cacheid;
 	xc_hash_t  *hcache; /* hash to cacheid */
 
-	time_t     compiling;
-	zend_ulong updates;
-	zend_ulong hits;
-	zend_ulong clogs;
-	zend_ulong ooms;
-	zend_ulong errors;
 	struct _xc_lock_t  *lck;
 	struct _xc_shm_t   *shm; /* which shm contains us */
 	struct _xc_mem_t   *mem; /* which mem contains us */
 
-	xc_entry_t **entries;
-	int entries_count;
-	xc_entry_data_php_t **phps;
-	int phps_count;
-	xc_entry_t *deletes;
-	int deletes_count;
 	xc_hash_t  *hentry; /* hash settings to entry */
 	xc_hash_t  *hphp;   /* hash settings to php */
-
-	time_t     last_gc_deletes;
-	time_t     last_gc_expires;
-
-	time_t     hits_by_hour_cur_time;
-	zend_uint  hits_by_hour_cur_slot;
-	zend_ulong hits_by_hour[24];
-	time_t     hits_by_second_cur_time;
-	zend_uint  hits_by_second_cur_slot;
-	zend_ulong hits_by_second[5];
+	xc_cached_t *cached;
 } xc_cache_t;
 /* }}} */
Index: trunk/mod_cacher/xc_cacher.c
===================================================================
--- trunk/mod_cacher/xc_cacher.c	(revision 1061)
+++ trunk/mod_cacher/xc_cacher.c	(revision 1062)
@@ -59,9 +59,36 @@
 /* }}} */
 
-/* {{{ types */
-struct _xc_hash_t {
+struct _xc_hash_t { /* {{{ */
 	size_t bits;
 	size_t size;
 	xc_hash_value_t mask;
+};
+/* }}} */
+struct _xc_cached_t { /* {{{ stored in shm */
+	int cacheid;
+
+	time_t     compiling;
+	zend_ulong updates;
+	zend_ulong hits;
+	zend_ulong clogs;
+	zend_ulong ooms;
+	zend_ulong errors;
+
+	xc_entry_t **entries;
+	int entries_count;
+	xc_entry_data_php_t **phps;
+	int phps_count;
+	xc_entry_t *deletes;
+	int deletes_count;
+
+	time_t     last_gc_deletes;
+	time_t     last_gc_expires;
+
+	time_t     hits_by_hour_cur_time;
+	zend_uint  hits_by_hour_cur_slot;
+	zend_ulong hits_by_hour[24];
+	time_t     hits_by_second_cur_time;
+	zend_uint  hits_by_second_cur_slot;
+	zend_ulong hits_by_second[5];
 };
 /* }}} */
@@ -88,6 +115,6 @@
 static zend_ulong xc_var_size  = 0;
 
-static xc_cache_t **xc_php_caches = NULL;
-static xc_cache_t **xc_var_caches = NULL;
+static xc_cache_t *xc_php_caches = NULL;
+static xc_cache_t *xc_var_caches = NULL;
 
 static zend_bool xc_initized = 0;
@@ -114,10 +141,10 @@
 /* any function in *_unlocked is only safe be called within locked (single thread access) area */
 
-static void xc_php_add_unlocked(xc_cache_t *cache, xc_entry_data_php_t *php) /* {{{ */
-{
-	xc_entry_data_php_t **head = &(cache->phps[php->hvalue]);
+static void xc_php_add_unlocked(xc_cached_t *cached, xc_entry_data_php_t *php) /* {{{ */
+{
+	xc_entry_data_php_t **head = &(cached->phps[php->hvalue]);
 	php->next = *head;
 	*head = php;
-	cache->phps_count ++;
+	cached->phps_count ++;
 }
 /* }}} */
@@ -130,17 +157,17 @@
 	stored_php = xc_processor_store_xc_entry_data_php_t(cache, php TSRMLS_CC);
 	if (stored_php) {
-		xc_php_add_unlocked(cache, stored_php);
+		xc_php_add_unlocked(cache->cached, stored_php);
 		return stored_php;
 	}
 	else {
-		cache->ooms ++;
+		cache->cached->ooms ++;
 		return NULL;
 	}
 }
 /* }}} */
-static xc_entry_data_php_t *xc_php_find_unlocked(xc_cache_t *cache, xc_entry_data_php_t *php TSRMLS_DC) /* {{{ */
+static xc_entry_data_php_t *xc_php_find_unlocked(xc_cached_t *cached, xc_entry_data_php_t *php TSRMLS_DC) /* {{{ */
 {
 	xc_entry_data_php_t *p;
-	for (p = cache->phps[php->hvalue]; p; p = (xc_entry_data_php_t *) p->next) {
+	for (p = cached->phps[php->hvalue]; p; p = (xc_entry_data_php_t *) p->next) {
 		if (memcmp(&php->md5.digest, &p->md5.digest, sizeof(php->md5.digest)) == 0) {
 			p->hits ++;
@@ -164,5 +191,5 @@
 {
 	if (-- php->refcount == 0) {
-		xc_entry_data_php_t **pp = &(cache->phps[php->hvalue]);
+		xc_entry_data_php_t **pp = &(cache->cached->phps[php->hvalue]);
 		xc_entry_data_php_t *p;
 		for (p = *pp; p; pp = &(p->next), p = p->next) {
@@ -259,10 +286,10 @@
 }
 /* }}} */
-static void xc_entry_add_unlocked(xc_cache_t *cache, xc_hash_value_t entryslotid, xc_entry_t *entry) /* {{{ */
-{
-	xc_entry_t **head = &(cache->entries[entryslotid]);
+static void xc_entry_add_unlocked(xc_cached_t *cached, xc_hash_value_t entryslotid, xc_entry_t *entry) /* {{{ */
+{
+	xc_entry_t **head = &(cached->entries[entryslotid]);
 	entry->next = *head;
 	*head = entry;
-	cache->entries_count ++;
+	cached->entries_count ++;
 }
 /* }}} */
@@ -278,10 +305,10 @@
 		: (xc_entry_t *) xc_processor_store_xc_entry_var_t(cache, (xc_entry_var_t *) entry TSRMLS_CC);
 	if (stored_entry) {
-		xc_entry_add_unlocked(cache, entryslotid, stored_entry);
-		++cache->updates;
+		xc_entry_add_unlocked(cache->cached, entryslotid, stored_entry);
+		++cache->cached->updates;
 		return stored_entry;
 	}
 	else {
-		cache->ooms ++;
+		cache->cached->ooms ++;
 		return NULL;
 	}
@@ -308,13 +335,13 @@
 static void xc_entry_free_unlocked(xc_entry_type_t type, xc_cache_t *cache, xc_entry_t *entry TSRMLS_DC) /* {{{ */
 {
-	cache->entries_count --;
+	cache->cached->entries_count --;
 	if ((type == XC_TYPE_PHP ? ((xc_entry_php_t *) entry)->refcount : 0) == 0) {
 		xc_entry_free_real_unlocked(type, cache, entry);
 	}
 	else {
-		entry->next = cache->deletes;
-		cache->deletes = entry;
+		entry->next = cache->cached->deletes;
+		cache->cached->deletes = entry;
 		entry->dtime = XG(request_time);
-		cache->deletes_count ++;
+		cache->cached->deletes_count ++;
 	}
 	return;
@@ -323,5 +350,5 @@
 static void xc_entry_remove_unlocked(xc_entry_type_t type, xc_cache_t *cache, xc_hash_value_t entryslotid, xc_entry_t *entry TSRMLS_DC) /* {{{ */
 {
-	xc_entry_t **pp = &(cache->entries[entryslotid]);
+	xc_entry_t **pp = &(cache->cached->entries[entryslotid]);
 	xc_entry_t *p;
 	for (p = *pp; p; pp = &(p->next), p = p->next) {
@@ -339,5 +366,5 @@
 {
 	xc_entry_t *p;
-	for (p = cache->entries[entryslotid]; p; p = p->next) {
+	for (p = cache->cached->entries[entryslotid]; p; p = p->next) {
 		if (xc_entry_equal_unlocked(type, entry, p TSRMLS_CC)) {
 			zend_bool fresh;
@@ -407,18 +434,18 @@
 }
 /* }}} */
-static inline void xc_cache_hit_unlocked(xc_cache_t *cache TSRMLS_DC) /* {{{ */
-{
-	cache->hits ++;
-
-	xc_counters_inc(&cache->hits_by_hour_cur_time
-			, &cache->hits_by_hour_cur_slot, 60 * 60
-			, cache->hits_by_hour
-			, sizeof(cache->hits_by_hour) / sizeof(cache->hits_by_hour[0])
+static inline void xc_cached_hit_unlocked(xc_cached_t *cached TSRMLS_DC) /* {{{ */
+{
+	cached->hits ++;
+
+	xc_counters_inc(&cached->hits_by_hour_cur_time
+			, &cached->hits_by_hour_cur_slot, 60 * 60
+			, cached->hits_by_hour
+			, sizeof(cached->hits_by_hour) / sizeof(cached->hits_by_hour[0])
 			TSRMLS_CC);
 
-	xc_counters_inc(&cache->hits_by_second_cur_time
-			, &cache->hits_by_second_cur_slot, 1
-			, cache->hits_by_second
-			, sizeof(cache->hits_by_second) / sizeof(cache->hits_by_second[0])
+	xc_counters_inc(&cached->hits_by_second_cur_time
+			, &cached->hits_by_second_cur_slot, 1
+			, cached->hits_by_second
+			, sizeof(cached->hits_by_second) / sizeof(cached->hits_by_second[0])
 			TSRMLS_CC);
 }
@@ -434,5 +461,5 @@
 
 	for (i = 0, c = cache->hentry->size; i < c; i ++) {
-		pp = &(cache->entries[i]);
+		pp = &(cache->cached->entries[i]);
 		for (p = *pp; p; p = *pp) {
 			if (apply_func(p TSRMLS_CC)) {
@@ -473,9 +500,9 @@
 static void xc_gc_expires_one(xc_entry_type_t type, xc_cache_t *cache, zend_ulong gc_interval, cache_apply_unlocked_func_t apply_func TSRMLS_DC) /* {{{ */
 {
-	TRACE("interval %lu, %lu %lu", (zend_ulong) XG(request_time), (zend_ulong) cache->last_gc_expires, gc_interval);
-	if (XG(request_time) >= cache->last_gc_expires + (time_t) gc_interval) {
+	TRACE("interval %lu, %lu %lu", (zend_ulong) XG(request_time), (zend_ulong) cache->cached->last_gc_expires, gc_interval);
+	if (XG(request_time) >= cache->cached->last_gc_expires + (time_t) gc_interval) {
 		ENTER_LOCK(cache) {
-			if (XG(request_time) >= cache->last_gc_expires + (time_t) gc_interval) {
-				cache->last_gc_expires = XG(request_time);
+			if (XG(request_time) >= cache->cached->last_gc_expires + (time_t) gc_interval) {
+				cache->cached->last_gc_expires = XG(request_time);
 				xc_entry_apply_unlocked(type, cache, apply_func TSRMLS_CC);
 			}
@@ -493,5 +520,5 @@
 
 	for (i = 0, c = xc_php_hcache.size; i < c; i ++) {
-		xc_gc_expires_one(XC_TYPE_PHP, xc_php_caches[i], xc_php_gc_interval, xc_gc_expires_php_entry_unlocked TSRMLS_CC);
+		xc_gc_expires_one(XC_TYPE_PHP, &xc_php_caches[i], xc_php_gc_interval, xc_gc_expires_php_entry_unlocked TSRMLS_CC);
 	}
 }
@@ -506,5 +533,5 @@
 
 	for (i = 0, c = xc_var_hcache.size; i < c; i ++) {
-		xc_gc_expires_one(XC_TYPE_VAR, xc_var_caches[i], xc_var_gc_interval, xc_gc_expires_var_entry_unlocked TSRMLS_CC);
+		xc_gc_expires_one(XC_TYPE_VAR, &xc_var_caches[i], xc_var_gc_interval, xc_gc_expires_var_entry_unlocked TSRMLS_CC);
 	}
 }
@@ -515,5 +542,5 @@
 	xc_entry_t *p, **pp;
 
-	pp = &cache->deletes;
+	pp = &cache->cached->deletes;
 	for (p = *pp; p; p = *pp) {
 		xc_entry_php_t *entry = (xc_entry_php_t *) p;
@@ -525,5 +552,5 @@
 			/* unlink */
 			*pp = p->next;
-			cache->deletes_count --;
+			cache->cached->deletes_count --;
 			xc_entry_free_real_unlocked(XC_TYPE_PHP, cache, p);
 		}
@@ -536,8 +563,8 @@
 static XC_CACHE_APPLY_FUNC(xc_gc_deletes_one) /* {{{ */
 {
-	if (cache->deletes && XG(request_time) - cache->last_gc_deletes > xc_deletes_gc_interval) {
+	if (cache->cached->deletes && XG(request_time) - cache->cached->last_gc_deletes > xc_deletes_gc_interval) {
 		ENTER_LOCK(cache) {
-			if (cache->deletes && XG(request_time) - cache->last_gc_deletes > xc_deletes_gc_interval) {
-				cache->last_gc_deletes = XG(request_time);
+			if (cache->cached->deletes && XG(request_time) - cache->cached->last_gc_deletes > xc_deletes_gc_interval) {
+				cache->cached->last_gc_deletes = XG(request_time);
 				xc_gc_delete_unlocked(cache TSRMLS_CC);
 			}
@@ -552,5 +579,5 @@
 	if (xc_php_caches) {
 		for (i = 0, c = xc_php_hcache.size; i < c; i ++) {
-			xc_gc_deletes_one(xc_php_caches[i] TSRMLS_CC);
+			xc_gc_deletes_one(&xc_php_caches[i] TSRMLS_CC);
 		}
 	}
@@ -558,5 +585,5 @@
 	if (xc_var_caches) {
 		for (i = 0, c = xc_var_hcache.size; i < c; i ++) {
-			xc_gc_deletes_one(xc_var_caches[i] TSRMLS_CC);
+			xc_gc_deletes_one(&xc_var_caches[i] TSRMLS_CC);
 		}
 	}
@@ -573,7 +600,9 @@
 	xc_memsize_t avail = 0;
 #endif
-	xc_mem_t *mem = cache->mem;
+	const xc_mem_t *mem = cache->mem;
 	const xc_mem_handlers_t *handlers = mem->handlers;
 	zend_ulong interval;
+	const xc_cached_t *cached = cache->cached;
+
 	if (cachetype == XC_TYPE_PHP) {
 		interval = xc_php_ttl ? xc_php_gc_interval : 0;
@@ -584,16 +613,16 @@
 
 	add_assoc_long_ex(return_value, ZEND_STRS("slots"),     cache->hentry->size);
-	add_assoc_long_ex(return_value, ZEND_STRS("compiling"), cache->compiling);
-	add_assoc_long_ex(return_value, ZEND_STRS("updates"),   cache->updates);
-	add_assoc_long_ex(return_value, ZEND_STRS("misses"),    cache->updates); /* deprecated */
-	add_assoc_long_ex(return_value, ZEND_STRS("hits"),      cache->hits);
-	add_assoc_long_ex(return_value, ZEND_STRS("clogs"),     cache->clogs);
-	add_assoc_long_ex(return_value, ZEND_STRS("ooms"),      cache->ooms);
-	add_assoc_long_ex(return_value, ZEND_STRS("errors"),    cache->errors);
-
-	add_assoc_long_ex(return_value, ZEND_STRS("cached"),    cache->entries_count);
-	add_assoc_long_ex(return_value, ZEND_STRS("deleted"),   cache->deletes_count);
+	add_assoc_long_ex(return_value, ZEND_STRS("compiling"), cached->compiling);
+	add_assoc_long_ex(return_value, ZEND_STRS("updates"),   cached->updates);
+	add_assoc_long_ex(return_value, ZEND_STRS("misses"),    cached->updates); /* deprecated */
+	add_assoc_long_ex(return_value, ZEND_STRS("hits"),      cached->hits);
+	add_assoc_long_ex(return_value, ZEND_STRS("clogs"),     cached->clogs);
+	add_assoc_long_ex(return_value, ZEND_STRS("ooms"),      cached->ooms);
+	add_assoc_long_ex(return_value, ZEND_STRS("errors"),    cached->errors);
+
+	add_assoc_long_ex(return_value, ZEND_STRS("cached"),    cached->entries_count);
+	add_assoc_long_ex(return_value, ZEND_STRS("deleted"),   cached->deletes_count);
 	if (interval) {
-		time_t gc = (cache->last_gc_expires + interval) - XG(request_time);
+		time_t gc = (cached->last_gc_expires + interval) - XG(request_time);
 		add_assoc_long_ex(return_value, ZEND_STRS("gc"),    gc > 0 ? gc : 0);
 	}
@@ -603,6 +632,6 @@
 	MAKE_STD_ZVAL(hits);
 	array_init(hits);
-	for (i = 0; i < sizeof(cache->hits_by_hour) / sizeof(cache->hits_by_hour[0]); i ++) {
-		add_next_index_long(hits, (long) cache->hits_by_hour[i]);
+	for (i = 0; i < sizeof(cached->hits_by_hour) / sizeof(cached->hits_by_hour[0]); i ++) {
+		add_next_index_long(hits, (long) cached->hits_by_hour[i]);
 	}
 	add_assoc_zval_ex(return_value, ZEND_STRS("hits_by_hour"), hits);
@@ -610,6 +639,6 @@
 	MAKE_STD_ZVAL(hits);
 	array_init(hits);
-	for (i = 0; i < sizeof(cache->hits_by_second) / sizeof(cache->hits_by_second[0]); i ++) {
-		add_next_index_long(hits, (long) cache->hits_by_second[i]);
+	for (i = 0; i < sizeof(cached->hits_by_second) / sizeof(cached->hits_by_second[0]); i ++) {
+		add_next_index_long(hits, (long) cached->hits_by_second[i]);
 	}
 	add_assoc_zval_ex(return_value, ZEND_STRS("hits_by_second"), hits);
@@ -721,5 +750,5 @@
 
 	for (i = 0, c = cache->hentry->size; i < c; i ++) {
-		for (e = cache->entries[i]; e; e = e->next) {
+		for (e = cache->cached->entries[i]; e; e = e->next) {
 			xc_fillentry_unlocked(type, e, i, 0, list TSRMLS_CC);
 		}
@@ -729,5 +758,5 @@
 	ALLOC_INIT_ZVAL(list);
 	array_init(list);
-	for (e = cache->deletes; e; e = e->next) {
+	for (e = cache->cached->deletes; e; e = e->next) {
 		xc_fillentry_unlocked(XC_TYPE_PHP, e, 0, 1, list TSRMLS_CC);
 	}
@@ -817,5 +846,5 @@
 /* }}} */
 
-static inline void xc_entry_unholds_real(xc_stack_t *holds, xc_cache_t **caches, int cachecount TSRMLS_DC) /* {{{ */
+static inline void xc_entry_unholds_real(xc_stack_t *holds, xc_cache_t *caches, int cachecount TSRMLS_DC) /* {{{ */
 {
 	int i;
@@ -828,5 +857,5 @@
 		TRACE("holded %d items", xc_stack_count(s));
 		if (xc_stack_count(s)) {
-			cache = caches[i];
+			cache = &caches[i];
 			ENTER_LOCK(cache) {
 				while (xc_stack_count(s)) {
@@ -1024,5 +1053,5 @@
 	*entry_resolve_path_data->stored_entry = (xc_entry_php_t *) xc_entry_find_unlocked(
 			XC_TYPE_PHP
-			, xc_php_caches[compiler->entry_hash.cacheid]
+			, &xc_php_caches[compiler->entry_hash.cacheid]
 			, compiler->entry_hash.entryslotid
 			, (xc_entry_t *) &compiler->new_entry
@@ -1889,5 +1918,5 @@
 	xc_compiler_t *compiler = sandboxed_compiler->compiler;
 	zend_bool catched = 0;
-	xc_cache_t *cache = xc_php_caches[compiler->entry_hash.cacheid];
+	xc_cache_t *cache = &xc_php_caches[compiler->entry_hash.cacheid];
 	xc_entry_php_t *stored_entry;
 	xc_entry_data_php_t *stored_php;
@@ -1950,5 +1979,5 @@
 	}
 
-	cache->compiling = 0;
+	cache->cached->compiling = 0;
 	xc_free_php(&compiler->new_php TSRMLS_CC);
 
@@ -1975,7 +2004,7 @@
 	xc_free_php(&compiler->new_php TSRMLS_CC);
 
-	cache->compiling = 0;
+	cache->cached->compiling = 0;
 	if (catched) {
-		cache->errors ++;
+		cache->cached->errors ++;
 		zend_bailout();
 	}
@@ -2016,10 +2045,10 @@
 	zend_bool catched = 0;
 	zend_op_array *op_array;
-	xc_cache_t *cache = xc_php_caches[compiler->entry_hash.cacheid];
+	xc_cache_t *cache = &xc_php_caches[compiler->entry_hash.cacheid];
 	xc_sandboxed_compiler_t sandboxed_compiler;
 
 	/* stale clogs precheck */
-	if (XG(request_time) - cache->compiling < 30) {
-		cache->clogs ++;
+	if (XG(request_time) - cache->cached->compiling < 30) {
+		cache->cached->clogs ++;
 		return old_compile_file(h, type TSRMLS_CC);
 	}
@@ -2047,5 +2076,5 @@
 
 		if (stored_entry) {
-			xc_cache_hit_unlocked(cache TSRMLS_CC);
+			xc_cached_hit_unlocked(cache->cached TSRMLS_CC);
 
 			TRACE(" hit %d:%s, holding", compiler->new_entry.file_inode, stored_entry->entry.name.str.val);
@@ -2062,5 +2091,5 @@
 		}
 
-		stored_php = xc_php_find_unlocked(cache, &compiler->new_php TSRMLS_CC);
+		stored_php = xc_php_find_unlocked(cache->cached, &compiler->new_php TSRMLS_CC);
 
 		if (stored_php) {
@@ -2079,7 +2108,7 @@
 		}
 
-		if (XG(request_time) - cache->compiling < 30) {
+		if (XG(request_time) - cache->cached->compiling < 30) {
 			TRACE("%s", "miss php, but compiling");
-			cache->clogs ++;
+			cache->cached->clogs ++;
 			gaveup = 1;
 			break;
@@ -2087,9 +2116,9 @@
 
 		TRACE("%s", "miss php, going to compile");
-		cache->compiling = XG(request_time);
+		cache->cached->compiling = XG(request_time);
 	} LEAVE_LOCK_EX(cache);
 
 	if (catched) {
-		cache->compiling = 0;
+		cache->cached->compiling = 0;
 		zend_bailout();
 	}
@@ -2172,5 +2201,5 @@
 	if (xc_php_caches) {
 		for (i = 0; i < xc_php_hcache.size; i ++) {
-			shm = xc_php_caches[i]->shm;
+			shm = xc_php_caches[i].shm;
 			if (shm->handlers->is_readwrite(shm, p)) {
 				return 1;
@@ -2181,5 +2210,5 @@
 	if (xc_var_caches) {
 		for (i = 0; i < xc_var_hcache.size; i ++) {
-			shm = xc_var_caches[i]->shm;
+			shm = xc_var_caches[i].shm;
 			if (shm->handlers->is_readwrite(shm, p)) {
 				return 1;
@@ -2197,5 +2226,5 @@
 	if (xc_php_caches) {
 		for (i = 0; i < xc_php_hcache.size; i ++) {
-			shm = xc_php_caches[i]->shm;
+			shm = xc_php_caches[i].shm;
 			if (shm->handlers->is_readonly(shm, p)) {
 				return 1;
@@ -2206,5 +2235,5 @@
 	if (xc_var_caches) {
 		for (i = 0; i < xc_var_hcache.size; i ++) {
-			shm = xc_var_caches[i]->shm;
+			shm = xc_var_caches[i].shm;
 			if (shm->handlers->is_readonly(shm, p)) {
 				return 1;
@@ -2255,16 +2284,13 @@
 }
 /* }}} */
-static xc_shm_t *xc_cache_destroy(xc_cache_t **caches, xc_hash_t *hcache) /* {{{ */
+static xc_shm_t *xc_cache_destroy(xc_cache_t *caches, xc_hash_t *hcache) /* {{{ */
 {
 	size_t i;
-	xc_cache_t *cache;
 	xc_shm_t *shm = NULL;
 
-	if (!caches) {
-		return shm;
-	}
+	assert(caches);
 
 	for (i = 0; i < hcache->size; i ++) {
-		cache = caches[i];
+		xc_cache_t *cache = &caches[i];
 		if (cache) {
 			if (cache->lck) {
@@ -2285,7 +2311,7 @@
 }
 /* }}} */
-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) /* {{{ */
-{
-	xc_cache_t **caches = NULL, *cache;
+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) /* {{{ */
+{
+	xc_cache_t *caches = NULL;
 	xc_mem_t *mem;
 	time_t now = time(NULL);
@@ -2306,14 +2332,15 @@
 	}
 
-	CHECK(caches = calloc(hcache->size, sizeof(xc_cache_t *)), "caches OOM");
+	CHECK(caches = calloc(hcache->size, sizeof(xc_cache_t)), "caches OOM");
 
 	for (i = 0; i < hcache->size; i ++) {
-		CHECK(mem            = shm->handlers->meminit(shm, memsize), "Failed init memory allocator");
-		CHECK(cache          = mem->handlers->calloc(mem, 1, sizeof(xc_cache_t)), "cache OOM");
-		CHECK(cache->entries = mem->handlers->calloc(mem, hentry->size, sizeof(xc_entry_t*)), "entries OOM");
+		xc_cache_t *cache = &caches[i];
+		CHECK(mem                     = shm->handlers->meminit(shm, memsize), "Failed init memory allocator");
+		CHECK(cache->cached           = mem->handlers->calloc(mem, 1, sizeof(xc_cached_t)), "cache OOM");
+		CHECK(cache->cached->entries  = mem->handlers->calloc(mem, hentry->size, sizeof(xc_entry_t*)), "entries OOM");
 		if (hphp) {
-			CHECK(cache->phps= mem->handlers->calloc(mem, hphp->size, sizeof(xc_entry_data_php_t*)), "phps OOM");
-		}
-		CHECK(cache->lck     = xc_lock_init(NULL), "can't create lock");
+			CHECK(cache->cached->phps = mem->handlers->calloc(mem, hphp->size, sizeof(xc_entry_data_php_t*)), "phps OOM");
+		}
+		CHECK(cache->lck              = xc_lock_init(NULL), "can't create lock");
 
 		cache->hcache  = hcache;
@@ -2323,7 +2350,6 @@
 		cache->mem     = mem;
 		cache->cacheid = i;
-		cache->last_gc_deletes = now;
-		cache->last_gc_expires = now;
-		caches[i] = cache;
+		cache->cached->last_gc_deletes = now;
+		cache->cached->last_gc_expires = now;
 	}
 	return caches;
@@ -2577,9 +2603,9 @@
 	ENTER_LOCK(cache) {
 		for (entryslotid = 0, c = cache->hentry->size; entryslotid < c; entryslotid ++) {
-			for (e = cache->entries[entryslotid]; e; e = next) {
+			for (e = cache->cached->entries[entryslotid]; e; e = next) {
 				next = e->next;
 				xc_entry_remove_unlocked(type, cache, entryslotid, e TSRMLS_CC);
 			}
-			cache->entries[entryslotid] = NULL;
+			cache->cached->entries[entryslotid] = NULL;
 		}
 	} LEAVE_LOCK(cache);
@@ -2591,5 +2617,5 @@
 	long type;
 	int size;
-	xc_cache_t **caches, *cache;
+	xc_cache_t *caches, *cache;
 	long id = 0;
 
@@ -2648,5 +2674,5 @@
 			array_init(return_value);
 
-			cache = caches[id];
+			cache = &caches[id];
 			ENTER_LOCK(cache) {
 				if (optype == XC_OP_INFO) {
@@ -2667,9 +2693,9 @@
 			if (id == -1) {
 				for (id = 0; id < size; ++id) {
-					xc_clear(type, caches[id] TSRMLS_CC);
+					xc_clear(type, &caches[id] TSRMLS_CC);
 				}
 			}
 			else {
-				xc_clear(type, caches[id] TSRMLS_CC);
+				xc_clear(type, &caches[id] TSRMLS_CC);
 			}
 
@@ -2763,5 +2789,5 @@
 	}
 	xc_entry_var_init_key(&entry_var, &entry_hash, name TSRMLS_CC);
-	cache = xc_var_caches[entry_hash.cacheid];
+	cache = &xc_var_caches[entry_hash.cacheid];
 
 	ENTER_LOCK(cache) {
@@ -2770,5 +2796,5 @@
 			/* return */
 			xc_processor_restore_zval(return_value, stored_entry_var->value, stored_entry_var->have_references TSRMLS_CC);
-			xc_cache_hit_unlocked(cache TSRMLS_CC);
+			xc_cached_hit_unlocked(cache->cached TSRMLS_CC);
 		}
 		else {
@@ -2809,5 +2835,5 @@
 
 	xc_entry_var_init_key(&entry_var, &entry_hash, name TSRMLS_CC);
-	cache = xc_var_caches[entry_hash.cacheid];
+	cache = &xc_var_caches[entry_hash.cacheid];
 
 	ENTER_LOCK(cache) {
@@ -2839,10 +2865,10 @@
 	}
 	xc_entry_var_init_key(&entry_var, &entry_hash, name TSRMLS_CC);
-	cache = xc_var_caches[entry_hash.cacheid];
+	cache = &xc_var_caches[entry_hash.cacheid];
 
 	ENTER_LOCK(cache) {
 		stored_entry_var = (xc_entry_var_t *) xc_entry_find_unlocked(XC_TYPE_VAR, cache, entry_hash.entryslotid, (xc_entry_t *) &entry_var TSRMLS_CC);
 		if (stored_entry_var) {
-			xc_cache_hit_unlocked(cache TSRMLS_CC);
+			xc_cached_hit_unlocked(cache->cached TSRMLS_CC);
 			RETVAL_TRUE;
 			/* return */
@@ -2873,5 +2899,5 @@
 	}
 	xc_entry_var_init_key(&entry_var, &entry_hash, name TSRMLS_CC);
-	cache = xc_var_caches[entry_hash.cacheid];
+	cache = &xc_var_caches[entry_hash.cacheid];
 
 	ENTER_LOCK(cache) {
@@ -2904,10 +2930,10 @@
 
 	for (i = 0, iend = xc_var_hcache.size; i < iend; i ++) {
-		xc_cache_t *cache = xc_var_caches[i];
+		xc_cache_t *cache = &xc_var_caches[i];
 		ENTER_LOCK(cache) {
 			int entryslotid, jend;
 			for (entryslotid = 0, jend = cache->hentry->size; entryslotid < jend; entryslotid ++) {
 				xc_entry_t *entry, *next;
-				for (entry = cache->entries[entryslotid]; entry; entry = next) {
+				for (entry = cache->cached->entries[entryslotid]; entry; entry = next) {
 					next = entry->next;
 					if (xc_entry_has_prefix_unlocked(XC_TYPE_VAR, entry, prefix)) {
@@ -2946,5 +2972,5 @@
 
 	xc_entry_var_init_key(&entry_var, &entry_hash, name TSRMLS_CC);
-	cache = xc_var_caches[entry_hash.cacheid];
+	cache = &xc_var_caches[entry_hash.cacheid];
 
 	ENTER_LOCK(cache) {
@@ -2964,5 +2990,5 @@
 				zv = (zval *) cache->shm->handlers->to_readwrite(cache->shm, (char *) stored_entry_var->value);
 				Z_LVAL_P(zv) = value;
-				++cache->updates;
+				++cache->cached->updates;
 				break; /* leave lock */
 			}
@@ -3208,5 +3234,7 @@
 	if (ext) {
 		/* zend_optimizer.optimization_level>0 is not compatible with other cacher, disabling */
+#if 0
 		ext->op_array_handler = NULL;
+#endif
 	}
 	/* cache if there's an op_array_ctor */
Index: trunk/xcache/xc_mem.h
===================================================================
--- trunk/xcache/xc_mem.h	(revision 1061)
+++ trunk/xcache/xc_mem.h	(revision 1062)
@@ -25,7 +25,7 @@
 #define XC_MEM_STRNDUP(func)         char *func(xc_mem_t *mem, const char *str, xc_memsize_t len)
 #define XC_MEM_STRDUP(func)          char *func(xc_mem_t *mem, const char *str)
-#define XC_MEM_AVAIL(func)           xc_memsize_t      func(xc_mem_t *mem)
-#define XC_MEM_SIZE(func)            xc_memsize_t      func(xc_mem_t *mem)
-#define XC_MEM_FREEBLOCK_FIRST(func) const xc_block_t *func(xc_mem_t *mem)
+#define XC_MEM_AVAIL(func)           xc_memsize_t      func(const xc_mem_t *mem)
+#define XC_MEM_SIZE(func)            xc_memsize_t      func(const xc_mem_t *mem)
+#define XC_MEM_FREEBLOCK_FIRST(func) const xc_block_t *func(const xc_mem_t *mem)
 #define XC_MEM_FREEBLOCK_NEXT(func)  const xc_block_t *func(const xc_block_t *block)
 #define XC_MEM_BLOCK_SIZE(func)      xc_memsize_t      func(const xc_block_t *block)
