Index: trunk/xcache.c
===================================================================
--- trunk/xcache.c	(revision 840)
+++ trunk/xcache.c	(revision 846)
@@ -38,11 +38,11 @@
 #include "utils.h"
 
-#define VAR_ENTRY_EXPIRED(pentry) ((pentry)->ttl && XG(request_time) > pentry->ctime + (pentry)->ttl)
+#define VAR_ENTRY_EXPIRED(pentry) ((pentry)->ttl && XG(request_time) > (pentry)->ctime + (pentry)->ttl)
 #define CHECK(x, e) do { if ((x) == NULL) { zend_error(E_ERROR, "XCache: " e); goto err; } } while (0)
-#define LOCK(x) xc_lock(x->lck)
-#define UNLOCK(x) xc_unlock(x->lck)
+#define LOCK(x) xc_lock((x)->lck)
+#define UNLOCK(x) xc_unlock((x)->lck)
 
 #define ENTER_LOCK_EX(x) \
-	xc_lock(x->lck); \
+	xc_lock((x)->lck); \
 	zend_try { \
 		do
@@ -52,5 +52,5 @@
 		catched = 1; \
 	} zend_end_try(); \
-	xc_unlock(x->lck)
+	xc_unlock((x)->lck)
 
 #define ENTER_LOCK(x) do { \
@@ -859,12 +859,12 @@
 	/* fall back to current directory */
 	if (zend_is_executing(TSRMLS_C)) {
-		char *path = zend_get_executed_filename(TSRMLS_C);
-		if (path && path[0] != '[') {
-			int len = strlen(path);
-			while ((--len >= 0) && !IS_SLASH(path[len])) {
+		const char *executed_filename = zend_get_executed_filename(TSRMLS_C);
+		if (executed_filename && executed_filename[0] != '[') {
+			int len = strlen(executed_filename);
+			while ((--len >= 0) && !IS_SLASH(executed_filename[len])) {
 				/* skipped */
 			}
 			if (len > 0 && len + strlen(filename) + 1 < MAXPATHLEN - 1) {
-				strcpy(filepath, path);
+				strcpy(filepath, executed_filename);
 				strcpy(filepath + len + 1, filename);
 				if (VCWD_STAT(filepath, pbuf) == 0) {
@@ -886,8 +886,8 @@
 
 #define HASH(i) (i)
-#define HASH_ZSTR_L(t, s, l) HASH(zend_u_inline_hash_func(t, s, (l + 1) * sizeof(UChar)))
-#define HASH_STR_S(s, l) HASH(zend_inline_hash_func(s, l))
-#define HASH_STR_L(s, l) HASH_STR_S(s, l + 1)
-#define HASH_STR(s) HASH_STR_L(s, strlen(s) + 1)
+#define HASH_ZSTR_L(t, s, l) HASH(zend_u_inline_hash_func((t), (s), ((l) + 1) * sizeof(UChar)))
+#define HASH_STR_S(s, l) HASH(zend_inline_hash_func((s), (l)))
+#define HASH_STR_L(s, l) HASH_STR_S((s), (l) + 1)
+#define HASH_STR(s) HASH_STR_L((s), strlen((s)) + 1)
 #define HASH_NUM(n) HASH(n)
 static inline xc_hash_value_t xc_hash_fold(xc_hash_value_t hvalue, const xc_hash_t *hasher) /* {{{ fold hash bits as needed */
@@ -962,13 +962,8 @@
 /* }}} */
 
-static int xc_entry_init_key_php(xc_entry_t *xce, char *filename TSRMLS_DC) /* {{{ */
+static int xc_entry_init_key_php(xc_entry_t *xce, const char *filename TSRMLS_DC) /* {{{ */
 {
 	char opened_path_buffer[MAXPATHLEN];
-	struct stat buf, *pbuf;
-	xc_hash_value_t hv;
 	int cacheid;
-	xc_entry_data_php_t *php;
-	char *ptr;
-	time_t delta;
 
 	if (!filename || !SG(request_info).path_translated) {
@@ -980,7 +975,7 @@
 	}
 
-	php = xce->data.php;
-
 	if (XG(stat)) {
+		struct stat buf, *pbuf;
+
 		if (strcmp(SG(request_info).path_translated, filename) == 0) {
 			/* sapi has already done this stat() for us */
@@ -1002,5 +997,5 @@
 		/* relative path */
 		if (*filename == '.' && (IS_SLASH(filename[1]) || filename[1] == '.')) {
-			ptr = filename + 1;
+			const char *ptr = filename + 1;
 			if (*ptr == '.') {
 				while (*(++ptr) == '.');
@@ -1025,7 +1020,9 @@
 
 stat_done:
-		delta = XG(request_time) - pbuf->st_mtime;
-		if (abs(delta) < 2 && !xc_test) {
-			return FAILURE;
+		{
+			time_t delta = XG(request_time) - pbuf->st_mtime;
+			if (abs(delta) < 2 && !xc_test) {
+				return FAILURE;
+			}
 		}
 
@@ -1035,5 +1032,5 @@
 		xce->inode        = pbuf->st_ino;
 #endif
-		php->sourcesize   = pbuf->st_size;
+		xce->data.php->sourcesize = pbuf->st_size;
 	}
 	else { /* XG(inode) */
@@ -1043,5 +1040,5 @@
 		xce->inode        = 0;
 #endif
-		php->sourcesize   = 0;
+		xce->data.php->sourcesize = 0;
 	}
 
@@ -1059,21 +1056,11 @@
 
 	UNISW(NOTHING, xce->name_type = IS_STRING;)
-	xce->name.str.val = filename;
+	xce->name.str.val = (char *) filename;
 	xce->name.str.len = strlen(filename);
 
-	if (xc_php_hcache.size > 1) {
-		hv = xc_entry_hash_php_basename(xce TSRMLS_CC);
-		cacheid = xc_hash_fold(hv, &xc_php_hcache);
-	}
-	else {
-		cacheid = 0;
-	}
+	cacheid = xc_php_hcache.size > 1 ? xc_hash_fold(xc_entry_hash_php_basename(xce TSRMLS_CC), &xc_php_hcache) : 0;
 	xce->cache = xc_php_caches[cacheid];
-
-	hv = xc_entry_hash_php(xce TSRMLS_CC);
-	xce->hvalue = xc_hash_fold(hv, &xc_php_hentry);
-
+	xce->hvalue = xc_hash_fold(xc_entry_hash_php(xce TSRMLS_CC), &xc_php_hentry);
 	xce->type = XC_TYPE_PHP;
-
 	xce->filepath  = NULL;
 	xce->dirpath   = NULL;
@@ -1088,5 +1075,5 @@
 static inline xc_hash_value_t xc_php_hash_md5(xc_entry_data_php_t *php TSRMLS_DC) /* {{{ */
 {
-	return HASH_STR_S(&php->md5, sizeof(php->md5));
+	return HASH_STR_S(php->md5.digest, sizeof(php->md5));
 }
 /* }}} */
@@ -1097,5 +1084,4 @@
 	int             n;
 	php_stream     *stream;
-	xc_hash_value_t hv;
 	ulong           old_rsid = EG(regular_list).nNextFreeElement;
 
@@ -1120,7 +1106,6 @@
 	}
 
-	hv = xc_php_hash_md5(php TSRMLS_CC);
 	php->cache  = xce->cache;
-	php->hvalue = (hv & php->cache->hphp->mask);
+	php->hvalue = (xc_php_hash_md5(php TSRMLS_CC) & php->cache->hphp->mask);
 #ifdef XCACHE_DEBUG
 	{
@@ -1134,5 +1119,5 @@
 }
 /* }}} */
-static void xc_entry_init_key_php_entry(xc_entry_t *xce, char *filepath TSRMLS_DC) /* {{{*/
+static void xc_entry_init_key_php_entry(xc_entry_t *xce, ZEND_24(const) char *filepath TSRMLS_DC) /* {{{*/
 {
 	xce->filepath     = filepath;
@@ -1518,5 +1503,5 @@
 	/* }}} */
 	/* {{{ prepare */
-	zend_restore_compiled_filename(h->opened_path ? h->opened_path : h->filename TSRMLS_CC);
+	zend_restore_compiled_filename(h->opened_path ? h->opened_path : (char *) h->filename TSRMLS_CC);
 	php->op_array      = op_array;
 
@@ -1890,7 +1875,7 @@
 	 */
 	if (xce->inode) {
-		char *filename = h->opened_path ? h->opened_path : h->filename;
+		const char *filename = h->opened_path ? h->opened_path : h->filename;
 		if (xce->name.str.val != filename) {
-			xce->name.str.val = filename;
+			xce->name.str.val = (char *) filename;
 			xce->name.str.len = strlen(filename);
 		}
@@ -1979,5 +1964,5 @@
 	xc_entry_t xce;
 	xc_entry_data_php_t php;
-	char *filename;
+	const char *filename;
 
 	assert(xc_initized);
