From: Greg Beaver Date: Mon, 16 Jun 2008 04:09:20 +0000 (+0000) Subject: fix hashtable creation for tar to be estimated size needed X-Git-Tag: php-5.3.0alpha1~736 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4e65a5814684cee6bb909387834f3530abe1cc65;p=php fix hashtable creation for tar to be estimated size needed --- diff --git a/ext/phar/tar.c b/ext/phar/tar.c index 618ff76997..92ecde46af 100644 --- a/ext/phar/tar.c +++ b/ext/phar/tar.c @@ -216,11 +216,12 @@ int phar_parse_tarfile(php_stream* fp, char *fname, int fname_len, char *alias, myphar = (phar_archive_data *) pecalloc(1, sizeof(phar_archive_data), PHAR_G(persist)); myphar->is_persistent = PHAR_G(persist); - zend_hash_init(&myphar->manifest, sizeof(phar_entry_info), + /* estimate number of entries, can't be certain with tar files */ + zend_hash_init(&myphar->manifest, 2 + (totalsize >> 12), zend_get_hash_value, destroy_phar_manifest_entry, myphar->is_persistent); - zend_hash_init(&myphar->mounted_dirs, sizeof(char *), + zend_hash_init(&myphar->mounted_dirs, 5, zend_get_hash_value, NULL, myphar->is_persistent); - zend_hash_init(&myphar->virtual_dirs, sizeof(char *), + zend_hash_init(&myphar->virtual_dirs, 4 + (totalsize >> 11), zend_get_hash_value, NULL, myphar->is_persistent); myphar->is_tar = 1; /* remember whether this entire phar was compressed with gz/bzip2 */