Index: /trunk/ChangeLog
===================================================================
--- /trunk/ChangeLog	(revision 704)
+++ /trunk/ChangeLog	(revision 705)
@@ -15,4 +15,5 @@
  * compatibility fix: fix segv on shutdown when ionCube Loader is loaded
  * fixed undefined index for xcache.count=1 and xcache.var_size>1
+ * fix builtin constant memory leak on compile
 
 1.3.1 2010-11-27
Index: /trunk/utils.c
===================================================================
--- /trunk/utils.c	(revision 704)
+++ /trunk/utils.c	(revision 705)
@@ -649,5 +649,5 @@
 }
 /* }}} */
-void xc_free_zend_constant(zend_constant *c) /* {{{ */
+static void xc_free_zend_constant(zend_constant *c) /* {{{ */
 {
 	if (!(c->flags & CONST_PERSISTENT)) {
@@ -702,8 +702,4 @@
 	zend_hash_init_ex(&TG(zend_constants),  20, NULL, (dtor_func_t) xc_free_zend_constant, h->persistent, h->bApplyProtection);
 	xc_copy_internal_zend_constants(&TG(zend_constants), &XG(internal_constant_table));
-	{
-		zend_constant tmp_const;
-		zend_hash_copy(&TG(zend_constants), &XG(internal_constant_table), (copy_ctor_func_t) xc_zend_constant_ctor, (void *) &tmp_const, sizeof(tmp_const));
-	}
 	TG(internal_constant_tail) = TG(zend_constants).pListTail;
 #endif
@@ -775,4 +771,9 @@
 
 #ifdef HAVE_XCACHE_CONSTANT
+	for (b = TG(zend_constants).pListHead; b != NULL && b != TG(internal_constant_tail); b = b->pListNext) {
+		zend_constant *c = (zend_constant*) b->pData;
+		xc_free_zend_constant(c);
+	}
+
 	b = TG(internal_constant_tail) ? TG(internal_constant_tail)->pListNext : TG(zend_constants).pListHead;
 	/* install constants */
