#endif
} /* }}} */
+static int phar_flush_clean_deleted_apply(void *data TSRMLS_DC) /* {{{ */
+{
+ phar_entry_info *entry = (phar_entry_info *)data;
+
+ if (entry->fp_refcount <= 0 && entry->is_deleted) {
+ return ZEND_HASH_APPLY_REMOVE;
+ } else {
+ return ZEND_HASH_APPLY_KEEP;
+ }
+}
+/* }}} */
+
/**
* Save phar contents to disk
*
}
manifest_ftell = php_stream_tell(newfile);
halt_offset = manifest_ftell;
-
+
+ /* Check whether we can get rid of some of the deleted entries which are
+ * unused. However some might still be in use so even after this clean-up
+ * we need to skip entries marked is_deleted. */
+ zend_hash_apply(&archive->manifest, phar_flush_clean_deleted_apply TSRMLS_CC);
+
/* compress as necessary, calculate crcs, manifest size, and file sizes */
new_manifest_count = 0;
offset = 0;