Index: /trunk/xcache.c
===================================================================
--- /trunk/xcache.c	(revision 851)
+++ /trunk/xcache.c	(revision 854)
@@ -113,17 +113,19 @@
 ZEND_DLEXPORT zend_extension zend_extension_entry;
 ZEND_DECLARE_MODULE_GLOBALS(xcache);
+
+typedef enum { XC_TYPE_PHP, XC_TYPE_VAR } xc_entry_type_t;
 /* }}} */
 
 /* any function in *_dmz is only safe be called within locked(single thread) area */
 
-static void xc_php_add_dmz(xc_entry_data_php_t *php) /* {{{ */
-{
-	xc_entry_data_php_t **head = &(php->cache->phps[php->hvalue]);
+static void xc_php_add_dmz(xc_cache_t *cache, xc_entry_data_php_t *php) /* {{{ */
+{
+	xc_entry_data_php_t **head = &(cache->phps[php->hvalue]);
 	php->next = *head;
 	*head = php;
-	php->cache->phps_count ++;
-}
-/* }}} */
-static xc_entry_data_php_t *xc_php_store_dmz(xc_entry_data_php_t *php TSRMLS_DC) /* {{{ */
+	cache->phps_count ++;
+}
+/* }}} */
+static xc_entry_data_php_t *xc_php_store_dmz(xc_cache_t *cache, xc_entry_data_php_t *php TSRMLS_DC) /* {{{ */
 {
 	xc_entry_data_php_t *stored_php;
@@ -131,19 +133,19 @@
 	php->hits     = 0;
 	php->refcount = 0;
-	stored_php = xc_processor_store_xc_entry_data_php_t(php TSRMLS_CC);
+	stored_php = xc_processor_store_xc_entry_data_php_t(cache, php TSRMLS_CC);
 	if (stored_php) {
-		xc_php_add_dmz(stored_php);
+		xc_php_add_dmz(cache, stored_php);
 		return stored_php;
 	}
 	else {
-		php->cache->ooms ++;
+		cache->ooms ++;
 		return NULL;
 	}
 }
 /* }}} */
-static xc_entry_data_php_t *xc_php_find_dmz(xc_entry_data_php_t *php TSRMLS_DC) /* {{{ */
+static xc_entry_data_php_t *xc_php_find_dmz(xc_cache_t *cache, xc_entry_data_php_t *php TSRMLS_DC) /* {{{ */
 {
 	xc_entry_data_php_t *p;
-	for (p = php->cache->phps[php->hvalue]; p; p = (xc_entry_data_php_t *) p->next) {
+	for (p = cache->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 ++;
@@ -154,7 +156,7 @@
 }
 /* }}} */
-static void xc_php_free_dmz(xc_entry_data_php_t *php) /* {{{ */
-{
-	php->cache->mem->handlers->free(php->cache->mem, (xc_entry_data_php_t *)php);
+static void xc_php_free_dmz(xc_cache_t *cache, xc_entry_data_php_t *php) /* {{{ */
+{
+	cache->mem->handlers->free(cache->mem, (xc_entry_data_php_t *)php);
 }
 /* }}} */
@@ -164,8 +166,8 @@
 }
 /* }}} */
-static void xc_php_release_dmz(xc_entry_data_php_t *php) /* {{{ */
+static void xc_php_release_dmz(xc_cache_t *cache, xc_entry_data_php_t *php) /* {{{ */
 {
 	if (-- php->refcount == 0) {
-		xc_entry_data_php_t **pp = &(php->cache->phps[php->hvalue]);
+		xc_entry_data_php_t **pp = &(cache->phps[php->hvalue]);
 		xc_entry_data_php_t *p;
 		for (p = *pp; p; pp = &(p->next), p = p->next) {
@@ -173,5 +175,5 @@
 				/* unlink */
 				*pp = p->next;
-				xc_php_free_dmz(php);
+				xc_php_free_dmz(cache, php);
 				return;
 			}
@@ -182,12 +184,8 @@
 /* }}} */
 
-static inline int xc_entry_equal_dmz(const xc_entry_t *entry1, const xc_entry_t *entry2) /* {{{ */
+static inline int xc_entry_equal_dmz(xc_entry_type_t type, const xc_entry_t *entry1, const xc_entry_t *entry2) /* {{{ */
 {
 	/* this function isn't required but can be in dmz */
-
-	if (entry1->type != entry2->type) {
-		return 0;
-	}
-	switch (entry1->type) {
+	switch (type) {
 		case XC_TYPE_PHP:
 #ifdef HAVE_INODE
@@ -225,50 +223,40 @@
 }
 /* }}} */
-static inline int xc_entry_has_prefix_dmz(xc_entry_t *entry, zval *prefix) /* {{{ */
+static inline int xc_entry_has_prefix_dmz(xc_entry_type_t type, xc_entry_t *entry, zval *prefix) /* {{{ */
 {
 	/* this function isn't required but can be in dmz */
 
-	switch (entry->type) {
-		case XC_TYPE_PHP:
-		case XC_TYPE_VAR:
-			do {
 #ifdef IS_UNICODE
-				if (entry->name_type != prefix->type) {
-					return 0;
-				}
-
-				if (entry->name_type == IS_UNICODE) {
-					if (entry->name.ustr.len < Z_USTRLEN_P(prefix)) {
-						return 0;
-					}
-					return memcmp(entry->name.ustr.val, Z_USTRVAL_P(prefix), Z_USTRLEN_P(prefix) * sizeof(UChar)) == 0;
-				}
-#endif
-				if (prefix->type != IS_STRING) {
-					return 0;
-				}
-
-				if (entry->name.str.len < Z_STRLEN_P(prefix)) {
-					return 0;
-				}
-
-				return memcmp(entry->name.str.val, Z_STRVAL_P(prefix), Z_STRLEN_P(prefix)) == 0;
-
-			} while(0);
-		default:
-			assert(0);
-	}
-	return 0;
-}
-/* }}} */
-static void xc_entry_add_dmz(xc_entry_t *xce) /* {{{ */
-{
-	xc_entry_t **head = &(xce->cache->entries[xce->hvalue]);
+	if (entry->name_type != prefix->type) {
+		return 0;
+	}
+
+	if (entry->name_type == IS_UNICODE) {
+		if (entry->name.ustr.len < Z_USTRLEN_P(prefix)) {
+			return 0;
+		}
+		return memcmp(entry->name.ustr.val, Z_USTRVAL_P(prefix), Z_USTRLEN_P(prefix) * sizeof(UChar)) == 0;
+	}
+#endif
+	if (prefix->type != IS_STRING) {
+		return 0;
+	}
+
+	if (entry->name.str.len < Z_STRLEN_P(prefix)) {
+		return 0;
+	}
+
+	return memcmp(entry->name.str.val, Z_STRVAL_P(prefix), Z_STRLEN_P(prefix)) == 0;
+}
+/* }}} */
+static void xc_entry_add_dmz(xc_cache_t *cache, xc_hash_value_t entryslotid, xc_entry_t *xce) /* {{{ */
+{
+	xc_entry_t **head = &(cache->entries[entryslotid]);
 	xce->next = *head;
 	*head = xce;
-	xce->cache->entries_count ++;
-}
-/* }}} */
-static xc_entry_t *xc_entry_store_dmz(xc_entry_t *xce TSRMLS_DC) /* {{{ */
+	cache->entries_count ++;
+}
+/* }}} */
+static xc_entry_t *xc_entry_store_dmz(xc_entry_type_t type, xc_cache_t *cache, xc_hash_value_t entryslotid, xc_entry_t *xce TSRMLS_DC) /* {{{ */
 {
 	xc_entry_t *stored_xce;
@@ -277,54 +265,54 @@
 	xce->ctime = XG(request_time);
 	xce->atime = XG(request_time);
-	stored_xce = xce->type == XC_TYPE_PHP
-		? (xc_entry_t *) xc_processor_store_xc_entry_php_t((xc_entry_php_t *) xce TSRMLS_CC)
-		: xc_processor_store_xc_entry_t(xce TSRMLS_CC);
+	stored_xce = type == XC_TYPE_PHP
+		? (xc_entry_t *) xc_processor_store_xc_entry_php_t(cache, (xc_entry_php_t *) xce TSRMLS_CC)
+		: xc_processor_store_xc_entry_t(cache, xce TSRMLS_CC);
 	if (stored_xce) {
-		xc_entry_add_dmz(stored_xce);
+		xc_entry_add_dmz(cache, entryslotid, stored_xce);
 		return stored_xce;
 	}
 	else {
-		xce->cache->ooms ++;
+		cache->ooms ++;
 		return NULL;
 	}
 }
 /* }}} */
-static xc_entry_php_t *xc_entry_php_store_dmz(xc_entry_php_t *xce TSRMLS_DC) /* {{{ */
-{
-	return (xc_entry_php_t *) xc_entry_store_dmz((xc_entry_t *) xce TSRMLS_CC);
-}
-/* }}} */
-static void xc_entry_free_real_dmz(volatile xc_entry_t *xce) /* {{{ */
-{
-	if (xce->type == XC_TYPE_PHP) {
-		xc_php_release_dmz(xce->data.php);
-	}
-	xce->cache->mem->handlers->free(xce->cache->mem, (xc_entry_t *)xce);
-}
-/* }}} */
-static void xc_entry_free_dmz(xc_entry_t *xce TSRMLS_DC) /* {{{ */
-{
-	xce->cache->entries_count --;
-	if ((xce->type == XC_TYPE_PHP ? ((xc_entry_php_t *) xce)->refcount : 0) == 0) {
-		xc_entry_free_real_dmz(xce);
+static xc_entry_php_t *xc_entry_php_store_dmz(xc_cache_t *cache, xc_hash_value_t entryslotid, xc_entry_php_t *xce TSRMLS_DC) /* {{{ */
+{
+	return (xc_entry_php_t *) xc_entry_store_dmz(XC_TYPE_PHP, cache, entryslotid, (xc_entry_t *) xce TSRMLS_CC);
+}
+/* }}} */
+static void xc_entry_free_real_dmz(xc_entry_type_t type, xc_cache_t *cache, volatile xc_entry_t *xce) /* {{{ */
+{
+	if (type == XC_TYPE_PHP) {
+		xc_php_release_dmz(cache, ((xc_entry_php_t *) xce)->php);
+	}
+	cache->mem->handlers->free(cache->mem, (xc_entry_t *)xce);
+}
+/* }}} */
+static void xc_entry_free_dmz(xc_entry_type_t type, xc_cache_t *cache, xc_entry_t *xce TSRMLS_DC) /* {{{ */
+{
+	cache->entries_count --;
+	if ((type == XC_TYPE_PHP ? ((xc_entry_php_t *) xce)->refcount : 0) == 0) {
+		xc_entry_free_real_dmz(type, cache, xce);
 	}
 	else {
-		xce->next = xce->cache->deletes;
-		xce->cache->deletes = xce;
+		xce->next = cache->deletes;
+		cache->deletes = xce;
 		xce->dtime = XG(request_time);
-		xce->cache->deletes_count ++;
+		cache->deletes_count ++;
 	}
 	return;
 }
 /* }}} */
-static void xc_entry_remove_dmz(xc_entry_t *xce TSRMLS_DC) /* {{{ */
-{
-	xc_entry_t **pp = &(xce->cache->entries[xce->hvalue]);
+static void xc_entry_remove_dmz(xc_entry_type_t type, xc_cache_t *cache, xc_hash_value_t entryslotid, xc_entry_t *xce TSRMLS_DC) /* {{{ */
+{
+	xc_entry_t **pp = &(cache->entries[entryslotid]);
 	xc_entry_t *p;
 	for (p = *pp; p; pp = &(p->next), p = p->next) {
-		if (xc_entry_equal_dmz(xce, p)) {
+		if (xc_entry_equal_dmz(type, xce, p)) {
 			/* unlink */
 			*pp = p->next;
-			xc_entry_free_dmz(xce TSRMLS_CC);
+			xc_entry_free_dmz(type, cache, xce TSRMLS_CC);
 			return;
 		}
@@ -333,16 +321,16 @@
 }
 /* }}} */
-static xc_entry_t *xc_entry_find_dmz(xc_entry_t *xce TSRMLS_DC) /* {{{ */
+static xc_entry_t *xc_entry_find_dmz(xc_entry_type_t type, xc_cache_t *cache, xc_hash_value_t entryslotid, xc_entry_t *xce TSRMLS_DC) /* {{{ */
 {
 	xc_entry_t *p;
-	for (p = xce->cache->entries[xce->hvalue]; p; p = p->next) {
-		if (xc_entry_equal_dmz(xce, p)) {
+	for (p = cache->entries[entryslotid]; p; p = p->next) {
+		if (xc_entry_equal_dmz(type, xce, p)) {
 			zend_bool fresh;
-			switch (p->type) {
+			switch (type) {
 			case XC_TYPE_PHP:
 				{
 					xc_entry_php_t *p_php = (xc_entry_php_t *) p;
 					xc_entry_php_t *xce_php = (xc_entry_php_t *) xce;
-					fresh = p_php->file_mtime == xce_php->file_mtime && p->data.php->file_size == xce->data.php->file_size;
+					fresh = p_php->file_mtime == xce_php->file_mtime && p_php->php->file_size == xce_php->php->file_size;
 					break;
 				}
@@ -362,5 +350,5 @@
 			}
 
-			xc_entry_remove_dmz(p TSRMLS_CC);
+			xc_entry_remove_dmz(type, cache, entryslotid, p TSRMLS_CC);
 			return NULL;
 		}
@@ -369,9 +357,9 @@
 }
 /* }}} */
-static void xc_entry_hold_php_dmz(xc_entry_php_t *xce TSRMLS_DC) /* {{{ */
+static void xc_entry_hold_php_dmz(xc_cache_t *cache, xc_entry_php_t *xce TSRMLS_DC) /* {{{ */
 {
 	TRACE("hold %s", xce->entry.name.str.val);
 	xce->refcount ++;
-	xc_stack_push(&XG(php_holds)[xce->entry.cache->cacheid], (void *)xce);
+	xc_stack_push(&XG(php_holds)[cache->cacheid], (void *)xce);
 }
 /* }}} */
@@ -437,5 +425,5 @@
 #define XC_ENTRY_APPLY_FUNC(name) int name(xc_entry_t *entry TSRMLS_DC)
 typedef XC_ENTRY_APPLY_FUNC((*cache_apply_dmz_func_t));
-static void xc_entry_apply_dmz(xc_cache_t *cache, cache_apply_dmz_func_t apply_func TSRMLS_DC) /* {{{ */
+static void xc_entry_apply_dmz(xc_entry_type_t type, xc_cache_t *cache, cache_apply_dmz_func_t apply_func TSRMLS_DC) /* {{{ */
 {
 	xc_entry_t *p, **pp;
@@ -448,5 +436,5 @@
 				/* unlink */
 				*pp = p->next;
-				xc_entry_free_dmz(p TSRMLS_CC);
+				xc_entry_free_dmz(type, cache, p TSRMLS_CC);
 			}
 			else {
@@ -480,5 +468,5 @@
 }
 /* }}} */
-static void xc_gc_expires_one(xc_cache_t *cache, zend_ulong gc_interval, cache_apply_dmz_func_t apply_func TSRMLS_DC) /* {{{ */
+static void xc_gc_expires_one(xc_entry_type_t type, xc_cache_t *cache, zend_ulong gc_interval, cache_apply_dmz_func_t apply_func TSRMLS_DC) /* {{{ */
 {
 	TRACE("interval %lu, %lu %lu", (zend_ulong) XG(request_time), (zend_ulong) cache->last_gc_expires, gc_interval);
@@ -487,5 +475,5 @@
 			if (XG(request_time) - cache->last_gc_expires >= gc_interval) {
 				cache->last_gc_expires = XG(request_time);
-				xc_entry_apply_dmz(cache, apply_func TSRMLS_CC);
+				xc_entry_apply_dmz(type, cache, apply_func TSRMLS_CC);
 			}
 		} LEAVE_LOCK(cache);
@@ -502,5 +490,5 @@
 
 	for (i = 0, c = xc_php_hcache.size; i < c; i ++) {
-		xc_gc_expires_one(xc_php_caches[i], xc_php_gc_interval, xc_gc_expires_php_entry_dmz TSRMLS_CC);
+		xc_gc_expires_one(XC_TYPE_PHP, xc_php_caches[i], xc_php_gc_interval, xc_gc_expires_php_entry_dmz TSRMLS_CC);
 	}
 }
@@ -515,5 +503,5 @@
 
 	for (i = 0, c = xc_var_hcache.size; i < c; i ++) {
-		xc_gc_expires_one(xc_var_caches[i], xc_var_gc_interval, xc_gc_expires_var_entry_dmz TSRMLS_CC);
+		xc_gc_expires_one(XC_TYPE_VAR, xc_var_caches[i], xc_var_gc_interval, xc_gc_expires_var_entry_dmz TSRMLS_CC);
 	}
 }
@@ -535,5 +523,5 @@
 			*pp = p->next;
 			cache->deletes_count --;
-			xc_entry_free_real_dmz(p);
+			xc_entry_free_real_dmz(XC_TYPE_PHP, cache, p);
 		}
 		else {
@@ -649,9 +637,8 @@
 }
 /* }}} */
-static void xc_fillentry_dmz(const xc_entry_t *entry, int del, zval *list TSRMLS_DC) /* {{{ */
+static void xc_fillentry_dmz(xc_entry_type_t type, const xc_entry_t *entry, xc_hash_value_t entryslotid, int del, zval *list TSRMLS_DC) /* {{{ */
 {
 	zval* ei;
 	const xc_entry_data_php_t *php;
-	const xc_entry_data_var_t *var;
 	xc_entry_php_t *entry_php = (xc_entry_php_t *) entry;
 
@@ -663,5 +650,5 @@
 	add_assoc_long_ex(ei, ZEND_STRS("ctime"),    entry->ctime);
 	add_assoc_long_ex(ei, ZEND_STRS("atime"),    entry->atime);
-	add_assoc_long_ex(ei, ZEND_STRS("hvalue"),   entry->hvalue);
+	add_assoc_long_ex(ei, ZEND_STRS("hvalue"),   entryslotid);
 	if (del) {
 		add_assoc_long_ex(ei, ZEND_STRS("dtime"), entry->dtime);
@@ -687,7 +674,7 @@
 	add_assoc_stringl_ex(ei, ZEND_STRS("name"), entry->name.str.val, entry->name.str.len, 1);
 #endif
-	switch (entry->type) {
+	switch (type) {
 		case XC_TYPE_PHP:
-			php = entry->data.php;
+			php = entry_php->php;
 			add_assoc_long_ex(ei, ZEND_STRS("size"),          entry->size + php->size);
 			add_assoc_long_ex(ei, ZEND_STRS("phprefcount"),   php->refcount);
@@ -710,5 +697,4 @@
 
 		case XC_TYPE_VAR:
-			var = &entry->data.var;
 			add_assoc_long_ex(ei, ZEND_STRS("size"),          entry->size);
 			break;
@@ -721,5 +707,5 @@
 }
 /* }}} */
-static void xc_filllist_dmz(xc_cache_t *cache, zval *return_value TSRMLS_DC) /* {{{ */
+static void xc_filllist_dmz(xc_entry_type_t type, xc_cache_t *cache, zval *return_value TSRMLS_DC) /* {{{ */
 {
 	zval* list;
@@ -732,5 +718,5 @@
 	for (i = 0, c = cache->hentry->size; i < c; i ++) {
 		for (e = cache->entries[i]; e; e = e->next) {
-			xc_fillentry_dmz(e, 0, list TSRMLS_CC);
+			xc_fillentry_dmz(type, e, i, 0, list TSRMLS_CC);
 		}
 	}
@@ -740,5 +726,5 @@
 	array_init(list);
 	for (e = cache->deletes; e; e = e->next) {
-		xc_fillentry_dmz(e, 1, list TSRMLS_CC);
+		xc_fillentry_dmz(XC_TYPE_PHP, e, 0, 1, list TSRMLS_CC);
 	}
 	add_assoc_zval(return_value, "deleted_list", list);
@@ -749,5 +735,5 @@
 {
 	zend_uint i;
-	xc_entry_data_php_t *p = xce->entry.data.php;
+	xc_entry_data_php_t *p = xce->php;
 	zend_op_array *old_active_op_array = CG(active_op_array);
 #ifndef ZEND_ENGINE_2
@@ -839,5 +825,5 @@
 		TRACE("holded %d", xc_stack_count(s));
 		if (xc_stack_count(s)) {
-			cache = ((xc_entry_t *)xc_stack_top(s))->cache;
+			cache = caches[i];
 			ENTER_LOCK(cache) {
 				while (xc_stack_count(s)) {
@@ -1007,8 +993,7 @@
 /* }}} */
 
-static int xc_entry_init_key_php(xc_entry_php_t *xce, const char *filename TSRMLS_DC) /* {{{ */
+static int xc_entry_init_key_php(xc_entry_hash_t *entry_hash, xc_entry_php_t *xce, const char *filename TSRMLS_DC) /* {{{ */
 {
 	char opened_path_buffer[MAXPATHLEN];
-	int cacheid;
 
 	if (!filename || !SG(request_info).path_translated) {
@@ -1077,5 +1062,5 @@
 		xce->file_inode   = pbuf->st_ino;
 #endif
-		xce->entry.data.php->file_size = pbuf->st_size;
+		xce->php->file_size = pbuf->st_size;
 	}
 	else { /* XG(inode) */
@@ -1085,5 +1070,5 @@
 		xce->file_inode   = 0;
 #endif
-		xce->entry.data.php->file_size = 0;
+		xce->php->file_size = 0;
 	}
 
@@ -1104,8 +1089,6 @@
 	xce->entry.name.str.len = strlen(filename);
 
-	cacheid = xc_php_hcache.size > 1 ? xc_hash_fold(xc_entry_hash_php_basename(xce TSRMLS_CC), &xc_php_hcache) : 0;
-	xce->entry.cache = xc_php_caches[cacheid];
-	xce->entry.hvalue = xc_hash_fold(xc_entry_hash_php(xce TSRMLS_CC), &xc_php_hentry);
-	xce->entry.type = XC_TYPE_PHP;
+	entry_hash->cacheslotid = xc_php_hcache.size > 1 ? xc_hash_fold(xc_entry_hash_php_basename(xce TSRMLS_CC), &xc_php_hcache) : 0;
+	entry_hash->entryslotid = xc_hash_fold(xc_entry_hash_php(xce TSRMLS_CC), &xc_php_hentry);
 	xce->filepath  = NULL;
 	xce->dirpath   = NULL;
@@ -1123,5 +1106,5 @@
 }
 /* }}} */
-static int xc_entry_init_key_php_md5(xc_entry_data_php_t *php, xc_entry_php_t *xce TSRMLS_DC) /* {{{ */
+static int xc_entry_init_key_php_md5(xc_cache_t *cache, xc_entry_data_php_t *php, xc_entry_php_t *xce TSRMLS_DC) /* {{{ */
 {
 	unsigned char   buf[1024];
@@ -1151,6 +1134,5 @@
 	}
 
-	php->cache  = xce->entry.cache;
-	php->hvalue = (xc_php_hash_md5(php TSRMLS_CC) & php->cache->hphp->mask);
+	php->hvalue = (xc_php_hash_md5(php TSRMLS_CC) & cache->hphp->mask);
 #ifdef XCACHE_DEBUG
 	{
@@ -1758,6 +1740,6 @@
 	TRACE("restoring %s", stored_xce->entry.name.str.val);
 	xc_processor_restore_xc_entry_php_t(&xce, stored_xce TSRMLS_CC);
-	xc_processor_restore_xc_entry_data_php_t(stored_xce, &php, xce.entry.data.php, xc_readonly_protection TSRMLS_CC);
-	xce.entry.data.php = &php;
+	xc_processor_restore_xc_entry_data_php_t(stored_xce, &php, xce.php, xc_readonly_protection TSRMLS_CC);
+	xce.php = &php;
 #ifdef SHOW_DPRINT
 	xc_dprint(&xce, 0 TSRMLS_CC);
@@ -1798,14 +1780,14 @@
 }
 /* }}} */
-static zend_op_array *xc_compile_file_ex(xc_entry_php_t *xce, zend_file_handle *h, int type TSRMLS_DC) /* {{{ */
+static zend_op_array *xc_compile_file_ex(xc_entry_hash_t *entry_hash, xc_entry_php_t *xce, zend_file_handle *h, int type TSRMLS_DC) /* {{{ */
 {
 	zend_op_array *op_array;
 	xc_entry_php_t *stored_xce;
 	xc_entry_data_php_t *stored_php;
-	xc_cache_t *cache = xce->entry.cache;
 	zend_bool gaveup = 0;
 	zend_bool catched = 0;
 	zend_bool newlycompiled;
 	xc_sandbox_t sandbox;
+	xc_cache_t *cache = xc_php_caches[entry_hash->cacheslotid];
 
 	/* stale clogs precheck */
@@ -1818,10 +1800,10 @@
 	stored_php = NULL;
 	ENTER_LOCK_EX(cache) {
-		stored_xce = (xc_entry_php_t *) xc_entry_find_dmz((xc_entry_t *) xce TSRMLS_CC);
+		stored_xce = (xc_entry_php_t *) xc_entry_find_dmz(XC_TYPE_PHP, cache, entry_hash->entryslotid, (xc_entry_t *) xce TSRMLS_CC);
 		if (stored_xce) {
 			xc_cache_hit_dmz(cache TSRMLS_CC);
 
 			TRACE("hit %s, holding", stored_xce->name.str.val);
-			xc_entry_hold_php_dmz(stored_xce TSRMLS_CC);
+			xc_entry_hold_php_dmz(cache, stored_xce TSRMLS_CC);
 		}
 		else {
@@ -1829,10 +1811,10 @@
 			TRACE("miss %s", xce->name.str.val);
 
-			if (xc_entry_init_key_php_md5(xce->entry.data.php, xce TSRMLS_CC) != SUCCESS) {
+			if (xc_entry_init_key_php_md5(cache, xce->php, xce TSRMLS_CC) != SUCCESS) {
 				gaveup = 1;
 				break;
 			}
 
-			stored_php = xc_php_find_dmz(xce->entry.data.php TSRMLS_CC);
+			stored_php = xc_php_find_dmz(cache, xce->php TSRMLS_CC);
 
 			/* miss but compiling */
@@ -1874,5 +1856,5 @@
 		newlycompiled = 0;
 		xc_entry_init_key_php_entry(xce, h->opened_path ? h->opened_path : h->filename TSRMLS_CC);
-		xce->entry.data.php = stored_php;
+		xce->php = stored_php;
 	}
 	else {
@@ -1883,16 +1865,16 @@
 
 #ifdef HAVE_XCACHE_CONSTANT
-		xce->entry.data.php->constinfos  = NULL;
-#endif
-		xce->entry.data.php->funcinfos   = NULL;
-		xce->entry.data.php->classinfos  = NULL;
+		xce->php->constinfos  = NULL;
+#endif
+		xce->php->funcinfos   = NULL;
+		xce->php->classinfos  = NULL;
 #ifdef ZEND_ENGINE_2_1
-		xce->entry.data.php->autoglobals = NULL;
-#endif
-
-		memset(&xce->entry.data.php->op_array_info, 0, sizeof(xce->entry.data.php->op_array_info));
+		xce->php->autoglobals = NULL;
+#endif
+
+		memset(&xce->php->op_array_info, 0, sizeof(xce->php->op_array_info));
 
 		zend_try {
-			op_array = xc_compile_php(xce, xce->entry.data.php, h, type TSRMLS_CC);
+			op_array = xc_compile_php(xce, xce->php, h, type TSRMLS_CC);
 		} zend_catch {
 			catched = 1;
@@ -1904,5 +1886,5 @@
 
 		/* not cachable */
-		if (!xce->entry.data.php->op_array) {
+		if (!xce->php->op_array) {
 			cache->compiling = 0;
 			/* it's not cachable, but don't scare the users with high misses */
@@ -1935,5 +1917,5 @@
 		/* php_store */
 		if (newlycompiled) {
-			stored_php = xc_php_store_dmz(xce->entry.data.php TSRMLS_CC);
+			stored_php = xc_php_store_dmz(cache, xce->php TSRMLS_CC);
 			if (!stored_php) {
 				/* error */
@@ -1943,11 +1925,11 @@
 		/* entry_store */
 		xc_php_addref_dmz(stored_php);
-		stored_xce = xc_entry_php_store_dmz(xce TSRMLS_CC);
+		stored_xce = xc_entry_php_store_dmz(cache, entry_hash->entryslotid, xce TSRMLS_CC);
 		if (stored_xce) {
-			stored_xce->entry.data.php = stored_php;
+			stored_xce->php = stored_php;
 		}
 		else {
 			/* error */
-			xc_php_release_dmz(stored_php);
+			xc_php_release_dmz(cache, stored_php);
 		}
 	} LEAVE_LOCK_EX(cache);
@@ -1961,5 +1943,5 @@
 
 	if (newlycompiled) {
-		xc_free_php(xce->entry.data.php TSRMLS_CC);
+		xc_free_php(xce->php TSRMLS_CC);
 	}
 
@@ -1992,5 +1974,5 @@
 err_aftersandbox:
 	if (newlycompiled) {
-		xc_free_php(xce->entry.data.php TSRMLS_CC);
+		xc_free_php(xce->php TSRMLS_CC);
 		xc_sandbox_free(&sandbox, XC_NoInstall TSRMLS_CC);
 	}
@@ -2008,4 +1990,5 @@
 	zend_op_array *op_array;
 	xc_entry_php_t xce;
+	xc_entry_hash_t entry_hash;
 	xc_entry_data_php_t php;
 	const char *filename;
@@ -2021,6 +2004,6 @@
 	/* {{{ entry_init_key */
 	filename = h->opened_path ? h->opened_path : h->filename;
-	xce.entry.data.php = &php;
-	if (xc_entry_init_key_php(&xce, filename TSRMLS_CC) != SUCCESS) {
+	xce.php = &php;
+	if (xc_entry_init_key_php(&entry_hash, &xce, filename TSRMLS_CC) != SUCCESS) {
 		TRACE("failed to init key for %s", filename);
 		return old_compile_file(h, type TSRMLS_CC);
@@ -2028,5 +2011,5 @@
 	/* }}} */
 
-	op_array = xc_compile_file_ex(&xce, h, type TSRMLS_CC);
+	op_array = xc_compile_file_ex(&entry_hash, &xce, h, type TSRMLS_CC);
 
 	xc_entry_free_key_php(&xce TSRMLS_CC);
@@ -2596,5 +2579,5 @@
 				}
 				else {
-					xc_filllist_dmz(cache, return_value TSRMLS_CC);
+					xc_filllist_dmz(type, cache, return_value TSRMLS_CC);
 				}
 			} LEAVE_LOCK(cache);
@@ -2603,5 +2586,5 @@
 			{
 				xc_entry_t *e, *next;
-				int i, c;
+				int entryslotid, c;
 
 				if (id < 0 || id >= size) {
@@ -2612,10 +2595,10 @@
 				cache = caches[id];
 				ENTER_LOCK(cache) {
-					for (i = 0, c = cache->hentry->size; i < c; i ++) {
-						for (e = cache->entries[i]; e; e = next) {
+					for (entryslotid = 0, c = cache->hentry->size; entryslotid < c; entryslotid ++) {
+						for (e = cache->entries[entryslotid]; e; e = next) {
 							next = e->next;
-							xc_entry_remove_dmz(e TSRMLS_CC);
+							xc_entry_remove_dmz(type, cache, entryslotid, e TSRMLS_CC);
 						}
-						cache->entries[i] = NULL;
+						cache->entries[entryslotid] = NULL;
 					}
 				} LEAVE_LOCK(cache);
@@ -2662,8 +2645,7 @@
 } while (0)
 
-static int xc_entry_init_key_var(xc_entry_t *xce, zval *name TSRMLS_DC) /* {{{ */
+static int xc_entry_init_key_var(xc_entry_hash_t *entry_hash, xc_entry_var_t *xce, zval *name TSRMLS_DC) /* {{{ */
 {
 	xc_hash_value_t hv;
-	int cacheid;
 
 	switch (Z_TYPE_P(name)) {
@@ -2681,16 +2663,13 @@
 	}
 #ifdef IS_UNICODE
-	xce->name_type = name->type;
-#endif
-	xce->name = name->value;
-
-	hv = xc_entry_hash_var(xce TSRMLS_CC);
-
-	cacheid = (hv & xc_var_hcache.mask);
-	xce->cache = xc_var_caches[cacheid];
+	xce->entry.name_type = name->type;
+#endif
+	xce->entry.name = name->value;
+
+	hv = xc_entry_hash_var((xc_entry_t *) xce TSRMLS_CC);
+
+	entry_hash->cacheslotid = (hv & xc_var_hcache.mask);
 	hv >>= xc_var_hcache.bits;
-	xce->hvalue = (hv & xc_var_hentry.mask);
-
-	xce->type = XC_TYPE_VAR;
+	entry_hash->entryslotid = (hv & xc_var_hentry.mask);
 	return SUCCESS;
 }
@@ -2700,5 +2679,7 @@
 PHP_FUNCTION(xcache_get)
 {
-	xc_entry_t xce, *stored_xce;
+	xc_entry_hash_t entry_hash;
+	xc_cache_t *cache;
+	xc_entry_var_t xce, *stored_xce;
 	zval *name;
 	int found = 0;
@@ -2712,27 +2693,28 @@
 		return;
 	}
-	xc_entry_init_key_var(&xce, name TSRMLS_CC);
-
-	ENTER_LOCK(xce.cache) {
-		stored_xce = xc_entry_find_dmz(&xce TSRMLS_CC);
+	xc_entry_init_key_var(&entry_hash, &xce, name TSRMLS_CC);
+	cache = xc_var_caches[entry_hash.cacheslotid];
+
+	ENTER_LOCK(cache) {
+		stored_xce = (xc_entry_var_t *) xc_entry_find_dmz(XC_TYPE_VAR, cache, entry_hash.cacheslotid, (xc_entry_t *) &xce TSRMLS_CC);
 		if (stored_xce) {
-			if (!VAR_ENTRY_EXPIRED(stored_xce)) {
+			if (!VAR_ENTRY_EXPIRED(&stored_xce->entry)) {
 				found = 1;
-				xc_processor_restore_zval(return_value, stored_xce->data.var.value, stored_xce->data.var.have_references TSRMLS_CC);
+				xc_processor_restore_zval(return_value, stored_xce->value, stored_xce->have_references TSRMLS_CC);
 				/* return */
 				break;
 			}
 			else {
-				xc_entry_remove_dmz(stored_xce TSRMLS_CC);
+				xc_entry_remove_dmz(XC_TYPE_VAR, cache, entry_hash.cacheslotid, (xc_entry_t *) stored_xce TSRMLS_CC);
 			}
 		}
 
 		RETVAL_NULL();
-	} LEAVE_LOCK(xce.cache);
+	} LEAVE_LOCK(cache);
 	if (found) {
-		xc_cache_hit_dmz(xce.cache TSRMLS_CC);
+		xc_cache_hit_dmz(cache TSRMLS_CC);
 	}
 	else {
-		xce.cache->misses ++;
+		cache->misses ++;
 	}
 }
@@ -2742,5 +2724,7 @@
 PHP_FUNCTION(xcache_set)
 {
-	xc_entry_t xce, *stored_xce;
+	xc_entry_hash_t entry_hash;
+	xc_cache_t *cache;
+	xc_entry_var_t xce, *stored_xce;
 	zval *name;
 	zval *value;
@@ -2751,24 +2735,25 @@
 	}
 
-	xce.ttl = XG(var_ttl);
-	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz|l", &name, &value, &xce.ttl) == FAILURE) {
+	xce.entry.ttl = XG(var_ttl);
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz|l", &name, &value, &xce.entry.ttl) == FAILURE) {
 		return;
 	}
 
 	/* max ttl */
-	if (xc_var_maxttl && (!xce.ttl || xce.ttl > xc_var_maxttl)) {
-		xce.ttl = xc_var_maxttl;
-	}
-
-	xc_entry_init_key_var(&xce, name TSRMLS_CC);
-
-	ENTER_LOCK(xce.cache) {
-		stored_xce = xc_entry_find_dmz(&xce TSRMLS_CC);
+	if (xc_var_maxttl && (!xce.entry.ttl || xce.entry.ttl > xc_var_maxttl)) {
+		xce.entry.ttl = xc_var_maxttl;
+	}
+
+	xc_entry_init_key_var(&entry_hash, &xce, name TSRMLS_CC);
+	cache = xc_var_caches[entry_hash.cacheslotid];
+
+	ENTER_LOCK(cache) {
+		stored_xce = (xc_entry_var_t *) xc_entry_find_dmz(XC_TYPE_VAR, cache, entry_hash.entryslotid, (xc_entry_t *) &xce TSRMLS_CC);
 		if (stored_xce) {
-			xc_entry_remove_dmz(stored_xce TSRMLS_CC);
-		}
-		xce.data.var.value = value;
-		RETVAL_BOOL(xc_entry_store_dmz(&xce TSRMLS_CC) != NULL ? 1 : 0);
-	} LEAVE_LOCK(xce.cache);
+			xc_entry_remove_dmz(XC_TYPE_VAR, cache, entry_hash.entryslotid, (xc_entry_t *) stored_xce TSRMLS_CC);
+		}
+		xce.value = value;
+		RETVAL_BOOL(xc_entry_store_dmz(XC_TYPE_VAR, cache, entry_hash.entryslotid, (xc_entry_t *) &xce TSRMLS_CC) != NULL ? 1 : 0);
+	} LEAVE_LOCK(cache);
 }
 /* }}} */
@@ -2777,5 +2762,7 @@
 PHP_FUNCTION(xcache_isset)
 {
-	xc_entry_t xce, *stored_xce;
+	xc_entry_hash_t entry_hash;
+	xc_cache_t *cache;
+	xc_entry_var_t xce, *stored_xce;
 	zval *name;
 	int found = 0;
@@ -2789,10 +2776,11 @@
 		return;
 	}
-	xc_entry_init_key_var(&xce, name TSRMLS_CC);
-
-	ENTER_LOCK(xce.cache) {
-		stored_xce = xc_entry_find_dmz(&xce TSRMLS_CC);
+	xc_entry_init_key_var(&entry_hash, &xce, name TSRMLS_CC);
+	cache = xc_var_caches[entry_hash.cacheslotid];
+
+	ENTER_LOCK(cache) {
+		stored_xce = (xc_entry_var_t *) xc_entry_find_dmz(XC_TYPE_VAR, cache, entry_hash.entryslotid, (xc_entry_t *) &xce TSRMLS_CC);
 		if (stored_xce) {
-			if (!VAR_ENTRY_EXPIRED(stored_xce)) {
+			if (!VAR_ENTRY_EXPIRED(&stored_xce->entry)) {
 				found = 1;
 				RETVAL_TRUE;
@@ -2801,15 +2789,15 @@
 			}
 			else {
-				xc_entry_remove_dmz(stored_xce TSRMLS_CC);
+				xc_entry_remove_dmz(XC_TYPE_VAR, cache, entry_hash.entryslotid, (xc_entry_t *) stored_xce TSRMLS_CC);
 			}
 		}
 
 		RETVAL_FALSE;
-	} LEAVE_LOCK(xce.cache);
+	} LEAVE_LOCK(cache);
 	if (found) {
-		xc_cache_hit_dmz(xce.cache TSRMLS_CC);
+		xc_cache_hit_dmz(cache TSRMLS_CC);
 	}
 	else {
-		xce.cache->misses ++;
+		cache->misses ++;
 	}
 }
@@ -2819,5 +2807,7 @@
 PHP_FUNCTION(xcache_unset)
 {
-	xc_entry_t xce, *stored_xce;
+	xc_entry_hash_t entry_hash;
+	xc_cache_t *cache;
+	xc_entry_var_t xce, *stored_xce;
 	zval *name;
 
@@ -2830,10 +2820,11 @@
 		return;
 	}
-	xc_entry_init_key_var(&xce, name TSRMLS_CC);
-
-	ENTER_LOCK(xce.cache) {
-		stored_xce = xc_entry_find_dmz(&xce TSRMLS_CC);
+	xc_entry_init_key_var(&entry_hash, &xce, name TSRMLS_CC);
+	cache = xc_var_caches[entry_hash.cacheslotid];
+
+	ENTER_LOCK(cache) {
+		stored_xce = (xc_entry_var_t *) xc_entry_find_dmz(XC_TYPE_VAR, cache, entry_hash.entryslotid, (xc_entry_t *) &xce TSRMLS_CC);
 		if (stored_xce) {
-			xc_entry_remove_dmz(stored_xce TSRMLS_CC);
+			xc_entry_remove_dmz(XC_TYPE_VAR, cache, entry_hash.entryslotid, (xc_entry_t *) stored_xce TSRMLS_CC);
 			RETVAL_TRUE;
 		}
@@ -2841,5 +2832,5 @@
 			RETVAL_FALSE;
 		}
-	} LEAVE_LOCK(xce.cache);
+	} LEAVE_LOCK(cache);
 }
 /* }}} */
@@ -2863,11 +2854,11 @@
 		xc_cache_t *cache = xc_var_caches[i];
 		ENTER_LOCK(cache) {
-			int j, jend;
-			for (j = 0, jend = cache->hentry->size; j < jend; j ++) {
+			int entryslotid, jend;
+			for (entryslotid = 0, jend = cache->hentry->size; entryslotid < jend; entryslotid ++) {
 				xc_entry_t *entry, *next;
-				for (entry = cache->entries[j]; entry; entry = next) {
+				for (entry = cache->entries[entryslotid]; entry; entry = next) {
 					next = entry->next;
-					if (xc_entry_has_prefix_dmz(entry, prefix)) {
-						xc_entry_remove_dmz(entry TSRMLS_CC);
+					if (xc_entry_has_prefix_dmz(XC_TYPE_VAR, entry, prefix)) {
+						xc_entry_remove_dmz(XC_TYPE_VAR, cache, entryslotid, entry TSRMLS_CC);
 					}
 				}
@@ -2879,5 +2870,7 @@
 static inline void xc_var_inc_dec(int inc, INTERNAL_FUNCTION_PARAMETERS) /* {{{ */
 {
-	xc_entry_t xce, *stored_xce;
+	xc_entry_hash_t entry_hash;
+	xc_cache_t *cache;
+	xc_entry_var_t xce, *stored_xce;
 	zval *name;
 	long count = 1;
@@ -2890,39 +2883,39 @@
 	}
 
-	xce.ttl = XG(var_ttl);
-	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|ll", &name, &count, &xce.ttl) == FAILURE) {
+	xce.entry.ttl = XG(var_ttl);
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|ll", &name, &count, &xce.entry.ttl) == FAILURE) {
 		return;
 	}
 
 	/* max ttl */
-	if (xc_var_maxttl && (!xce.ttl || xce.ttl > xc_var_maxttl)) {
-		xce.ttl = xc_var_maxttl;
-	}
-
-	xc_entry_init_key_var(&xce, name TSRMLS_CC);
-
-	ENTER_LOCK(xce.cache) {
-		stored_xce = xc_entry_find_dmz(&xce TSRMLS_CC);
+	if (xc_var_maxttl && (!xce.entry.ttl || xce.entry.ttl > xc_var_maxttl)) {
+		xce.entry.ttl = xc_var_maxttl;
+	}
+
+	xc_entry_init_key_var(&entry_hash, &xce, name TSRMLS_CC);
+	cache = xc_var_caches[entry_hash.cacheslotid];
+
+	ENTER_LOCK(cache) {
+		stored_xce = (xc_entry_var_t *) xc_entry_find_dmz(XC_TYPE_VAR, cache, entry_hash.cacheslotid, (xc_entry_t *) &xce TSRMLS_CC);
 		if (stored_xce) {
 			TRACE("incdec: gotxce %s", xce.name.str.val);
 			/* timeout */
-			if (VAR_ENTRY_EXPIRED(stored_xce)) {
+			if (VAR_ENTRY_EXPIRED(&(stored_xce->entry))) {
 				TRACE("%s", "incdec: expired");
-				xc_entry_remove_dmz(stored_xce TSRMLS_CC);
+				xc_entry_remove_dmz(XC_TYPE_VAR, cache, entry_hash.cacheslotid, (xc_entry_t *) stored_xce TSRMLS_CC);
 				stored_xce = NULL;
 			}
 			else {
 				/* do it in place */
-				xc_entry_data_var_t *stored_var = &stored_xce->data.var;
-				if (Z_TYPE_P(stored_var->value) == IS_LONG) {
+				if (Z_TYPE_P(stored_xce->value) == IS_LONG) {
 					zval *zv;
-					stored_xce->ctime = XG(request_time);
-					stored_xce->ttl   = xce.ttl;
+					stored_xce->entry.ctime = XG(request_time);
+					stored_xce->entry.ttl   = xce.entry.ttl;
 					TRACE("%s", "incdec: islong");
-					value = Z_LVAL_P(stored_var->value);
+					value = Z_LVAL_P(stored_xce->value);
 					value += (inc == 1 ? count : - count);
 					RETVAL_LONG(value);
 
-					zv = (zval *) xce.cache->shm->handlers->to_readwrite(xce.cache->shm, (char *) stored_var->value);
+					zv = (zval *) cache->shm->handlers->to_readwrite(cache->shm, (char *) stored_xce->value);
 					Z_LVAL_P(zv) = value;
 					break; /* leave lock */
@@ -2930,5 +2923,5 @@
 				else {
 					TRACE("%s", "incdec: notlong");
-					xc_processor_restore_zval(&oldzval, stored_xce->data.var.value, stored_xce->data.var.have_references TSRMLS_CC);
+					xc_processor_restore_zval(&oldzval, stored_xce->value, stored_xce->have_references TSRMLS_CC);
 					convert_to_long(&oldzval);
 					value = Z_LVAL(oldzval);
@@ -2943,15 +2936,15 @@
 		value += (inc == 1 ? count : - count);
 		RETVAL_LONG(value);
-		stored_xce->data.var.value = return_value;
+		stored_xce->value = return_value;
 
 		if (stored_xce) {
-			xce.atime = stored_xce->atime;
-			xce.ctime = stored_xce->ctime;
-			xce.hits  = stored_xce->hits;
-			xc_entry_remove_dmz(stored_xce TSRMLS_CC);
-		}
-		xc_entry_store_dmz(&xce TSRMLS_CC);
-
-	} LEAVE_LOCK(xce.cache);
+			xce.entry.atime = stored_xce->entry.atime;
+			xce.entry.ctime = stored_xce->entry.ctime;
+			xce.entry.hits  = stored_xce->entry.hits;
+			xc_entry_remove_dmz(XC_TYPE_VAR, cache, entry_hash.cacheslotid, (xc_entry_t *) stored_xce TSRMLS_CC);
+		}
+		xc_entry_store_dmz(XC_TYPE_VAR, cache, entry_hash.cacheslotid, (xc_entry_t *) &xce TSRMLS_CC);
+
+	} LEAVE_LOCK(cache);
 }
 /* }}} */
Index: /trunk/xcache.h
===================================================================
--- /trunk/xcache.h	(revision 851)
+++ /trunk/xcache.h	(revision 854)
@@ -355,5 +355,4 @@
 /* }}} */
 #endif
-typedef enum { XC_TYPE_PHP, XC_TYPE_VAR } xc_entry_type_t;
 typedef struct {
 	char digest[16];
@@ -369,7 +368,6 @@
 /* {{{ xc_entry_data_php_t */
 struct _xc_entry_data_php_t {
+	xc_entry_data_php_t *next;
 	xc_hash_value_t      hvalue;
-	xc_entry_data_php_t *next;
-	xc_cache_t          *cache;
 
 	xc_md5sum_t md5;        /* md5sum of the source */
@@ -410,21 +408,10 @@
 };
 /* }}} */
-/* {{{ xc_entry_data_var_t */
-typedef struct {
-	zval   *value;
-
-	zend_bool  have_references;
-} xc_entry_data_var_t;
-/* }}} */
 typedef zvalue_value xc_entry_name_t;
 /* {{{ xc_entry_t */
 struct _xc_entry_t {
-	xc_hash_value_t hvalue;
-	xc_entry_t     *next;
-	xc_cache_t     *cache;
-
-	xc_entry_type_t type;
-	size_t          size;
-
+	xc_entry_t *next;
+
+	size_t     size;
 	time_t     ctime;           /* creation ctime of this entry */
 	time_t     atime;           /*   access atime of this entry */
@@ -437,13 +424,9 @@
 #endif
 	xc_entry_name_t name;
-
-	union {
-		xc_entry_data_php_t *php;
-		xc_entry_data_var_t var;
-	} data;
 };
 
 typedef struct {
 	xc_entry_t entry;
+	xc_entry_data_php_t *php;
 
 	zend_ulong refcount;    /* count of php instances holding this entry */
@@ -466,4 +449,15 @@
 } xc_entry_php_t;
 /* }}} */
+typedef struct {
+	xc_entry_t entry;
+	zval      *value;
+	zend_bool  have_references;
+} xc_entry_var_t;
+/* }}} */
+typedef struct xc_entry_hash_t { /* {{{ */
+	xc_hash_value_t cacheslotid;
+	xc_hash_value_t entryslotid;
+} xc_entry_hash_t;
+/* }}} */
 
 extern zend_module_entry xcache_module_entry;
Index: /trunk/processor/head.m4
===================================================================
--- /trunk/processor/head.m4	(revision 851)
+++ /trunk/processor/head.m4	(revision 854)
@@ -389,6 +389,6 @@
 dnl ================ export API
 define(`DEFINE_STORE_API', `
-/* export: $1 *xc_processor_store_$1($1 *src TSRMLS_DC); :export {{{ */
-$1 *xc_processor_store_$1($1 *src TSRMLS_DC) {
+/* export: $1 *xc_processor_store_$1(xc_cache_t *cache, $1 *src TSRMLS_DC); :export {{{ */
+$1 *xc_processor_store_$1(xc_cache_t *cache, $1 *src TSRMLS_DC) {
 	$1 *dst;
 	xc_processor_t processor;
@@ -396,5 +396,5 @@
 	memset(&processor, 0, sizeof(processor));
 	processor.reference = 1;
-	processor.cache = src->ifelse(`$1', `xc_entry_php_t', entry.)cache;
+	processor.cache = cache;
 
 	IFASSERT(`xc_stack_init(&processor.allocsizes);')
@@ -418,5 +418,5 @@
 	src->ifelse(`$1', `xc_entry_php_t', entry.)size = processor.size;
 	ifelse(
-		`$1', `xc_entry_t', `src->data.var.have_references = processor.have_references;',
+		`$1', `xc_entry_var_t', `src->have_references = processor.have_references;',
 		`$1', `xc_entry_data_php_t', `src->have_references = processor.have_references;'
 	)
Index: /trunk/processor/processor.m4
===================================================================
--- /trunk/processor/processor.m4	(revision 851)
+++ /trunk/processor/processor.m4	(revision 854)
@@ -1067,8 +1067,7 @@
 	')
 
-	PROCESS(xc_hash_value_t, hvalue)
 	/* skip */
 	DONE(next)
-	COPY(cache)
+	PROCESS(xc_hash_value_t, hvalue)
 	PROCESS(xc_md5sum_t, md5)
 	PROCESS(zend_ulong, refcount)
@@ -1119,17 +1118,7 @@
 ')
 dnl }}}
-DEF_STRUCT_P_FUNC(`xc_entry_data_var_t', , `dnl {{{
-	IFDPRINT(`INDENT()`'fprintf(stderr, "zval:value");')
-	STRUCT_P_EX(zval_ptr, dst->value, src->value, `value', `', `&')
-	PROCESS(zend_bool, have_references)
-	DONE(value)
-')
-dnl }}}
 DEF_STRUCT_P_FUNC(`xc_entry_t', , `dnl {{{
-	PROCESS(xc_hash_value_t, hvalue)
 	/* skip */
 	DONE(next)
-	COPY(cache)
-	PROCESS(xc_entry_type_t, type)
 	PROCESS(size_t, size)
 
@@ -1164,26 +1153,9 @@
 	DONE(name)
 	dnl }}}
-
-	dnl {{{ data
-	DISABLECHECK(`
-		switch (src->type) {
-		case XC_TYPE_PHP:
-			IFCALCCOPY(`COPY(data.php)', `STRUCT_P(xc_entry_data_php_t, data.php)')
-			break;
-
-		case XC_TYPE_VAR:
-			STRUCT(xc_entry_data_var_t, data.var)
-			break;
-
-		default:
-			assert(0);
-		}
-	')
-	DONE(data)
-	dnl }}}
 ')
 dnl }}}
 DEF_STRUCT_P_FUNC(`xc_entry_php_t', , `dnl {{{
 	STRUCT(xc_entry_t, entry)
+	IFCALCCOPY(`COPY(php)', `STRUCT_P(xc_entry_data_php_t, php)')
 
 	IFSTORE(`dst->refcount = 0; DONE(refcount)', `PROCESS(long, refcount)')
@@ -1194,28 +1166,23 @@
 #endif
 
-	if (src->entry.type == XC_TYPE_PHP) {
-		PROCESS(int, filepath_len)
-		IFRESTORE(`COPY(filepath)', `PROC_STRING_L(filepath, filepath_len)')
-		PROCESS(int, dirpath_len)
-		IFRESTORE(`COPY(dirpath)', `PROC_STRING_L(dirpath, dirpath_len)')
+	PROCESS(int, filepath_len)
+	IFRESTORE(`COPY(filepath)', `PROC_STRING_L(filepath, filepath_len)')
+	PROCESS(int, dirpath_len)
+	IFRESTORE(`COPY(dirpath)', `PROC_STRING_L(dirpath, dirpath_len)')
 #ifdef IS_UNICODE
-		PROCESS(int, ufilepath_len)
-		IFRESTORE(`COPY(ufilepath)', `PROC_USTRING_L(ufilepath, ufilepath_len)')
-		PROCESS(int, udirpath_len)
-		IFRESTORE(`COPY(udirpath)', `PROC_USTRING_L(udirpath, udirpath_len)')
-#endif
-	}
-	else {
-		DONE(filepath_len)
-		DONE(filepath)
-		DONE(dirpath_len)
-		DONE(dirpath)
-#ifdef IS_UNICODE
-		DONE(ufilepath_len)
-		DONE(ufilepath)
-		DONE(udirpath_len)
-		DONE(udirpath)
-#endif
-	}
+	PROCESS(int, ufilepath_len)
+	IFRESTORE(`COPY(ufilepath)', `PROC_USTRING_L(ufilepath, ufilepath_len)')
+	PROCESS(int, udirpath_len)
+	IFRESTORE(`COPY(udirpath)', `PROC_USTRING_L(udirpath, udirpath_len)')
+#endif
+')
+dnl }}}
+DEF_STRUCT_P_FUNC(`xc_entry_var_t', , `dnl {{{
+	STRUCT(xc_entry_t, entry)
+
+	IFDPRINT(`INDENT()`'fprintf(stderr, "zval:value");')
+	STRUCT_P_EX(zval_ptr, dst->value, src->value, `value', `', `&')
+	PROCESS(zend_bool, have_references)
+	DONE(value)
 ')
 dnl }}}
