Index: /trunk/xcache.c
===================================================================
--- /trunk/xcache.c	(revision 16)
+++ /trunk/xcache.c	(revision 17)
@@ -990,4 +990,20 @@
 static void xc_request_init(TSRMLS_D) /* {{{ */
 {
+	int i;
+
+	if (xc_php_hcache.size && !XG(php_holds)) {
+		XG(php_holds) = calloc(xc_php_hcache.size, sizeof(xc_stack_t));
+		for (i = 0; i < xc_php_hcache.size; i ++) {
+			xc_stack_init(&XG(php_holds[i]));
+		}
+	}
+
+	if (xc_var_hcache.size && !XG(var_holds)) {
+		XG(var_holds) = calloc(xc_var_hcache.size, sizeof(xc_stack_t));
+		for (i = 0; i < xc_var_hcache.size; i ++) {
+			xc_stack_init(&XG(var_holds[i]));
+		}
+	}
+
 	if (XG(cacher)) {
 #if PHP_API_VERSION <= 20041225
@@ -1012,29 +1028,5 @@
 static void xc_init_globals(zend_xcache_globals* xc_globals TSRMLS_DC) /* {{{ */
 {
-	int i;
-
-	if (xc_php_hcache.size) {
-		xc_globals->php_holds = calloc(xc_php_hcache.size, sizeof(xc_stack_t));
-		for (i = 0; i < xc_php_hcache.size; i ++) {
-			xc_stack_init(&xc_globals->php_holds[i]);
-		}
-	}
-	else {
-		xc_globals->php_holds = NULL;
-	}
-
-	if (xc_var_hcache.size) {
-		xc_globals->var_holds = calloc(xc_var_hcache.size, sizeof(xc_stack_t));
-		for (i = 0; i < xc_var_hcache.size; i ++) {
-			xc_stack_init(&xc_globals->var_holds[i]);
-		}
-	}
-	else {
-		xc_globals->var_holds = NULL;
-	}
-
-#ifdef HAVE_XCACHE_COVERAGE
-	xc_globals->coverages = NULL;
-#endif
+	memset(xc_globals, 0, sizeof(zend_xcache_globals));
 }
 /* }}} */
@@ -1540,5 +1532,5 @@
 		return;
 	}
-	if (spec <= xc_get_opcode_spec_count()) {
+	if ((zend_uchar) spec <= xc_get_opcode_spec_count()) {
 		opspec = xc_get_opcode_spec((zend_uchar) spec);
 		if (opspec) {
@@ -1792,6 +1784,4 @@
 	char *env;
 
-	REGISTER_INI_ENTRIES();
-
 	xc_module_gotup = 1;
 	if (!xc_zend_extension_gotup) {
@@ -1802,4 +1792,7 @@
 	}
 
+	ZEND_INIT_MODULE_GLOBALS(xcache, xc_init_globals, xc_shutdown_globals);
+	REGISTER_INI_ENTRIES();
+
 	if (strcmp(sapi_module.name, "cli") == 0) {
 		if ((env = getenv("XCACHE_TEST")) != NULL) {
@@ -1818,7 +1811,4 @@
 		xc_var_size = xc_var_hcache.size = 0;
 	}
-	/* xc_init_globals depends on all the aboves */
-
-	ZEND_INIT_MODULE_GLOBALS(xcache, xc_init_globals, xc_shutdown_globals);
 
 	original_sigsegv_handler = signal(SIGSEGV, xcache_sigsegv_handler);
