Skip to content

Commit 33f5cb7

Browse files
committed
ext/phar: avoid redundant allocation by using zend_string for alias
1 parent 8b9558e commit 33f5cb7

File tree

9 files changed

+273
-214
lines changed

9 files changed

+273
-214
lines changed

ext/phar/dirstream.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ php_stream *phar_wrapper_open_dir(php_stream_wrapper *wrapper, const char *path,
276276

277277
phar_request_initialize();
278278

279-
if (FAILURE == phar_get_archive(&phar, ZSTR_VAL(resource->host), ZSTR_LEN(resource->host), NULL, 0, &error)) {
279+
if (FAILURE == phar_get_archive(&phar, ZSTR_VAL(resource->host), ZSTR_LEN(resource->host), NULL, &error)) {
280280
if (error) {
281281
php_stream_wrapper_log_error(wrapper, options, "%s", error);
282282
efree(error);
@@ -355,7 +355,7 @@ int phar_wrapper_mkdir(php_stream_wrapper *wrapper, const char *url_from, int mo
355355
return 0;
356356
}
357357

358-
if (FAILURE == phar_get_archive(&phar, arch, arch_len, NULL, 0, NULL)) {
358+
if (FAILURE == phar_get_archive(&phar, arch, arch_len, NULL, NULL)) {
359359
phar = NULL;
360360
}
361361

@@ -383,7 +383,7 @@ int phar_wrapper_mkdir(php_stream_wrapper *wrapper, const char *url_from, int mo
383383
return 0;
384384
}
385385

386-
if (FAILURE == phar_get_archive(&phar, ZSTR_VAL(resource->host), ZSTR_LEN(resource->host), NULL, 0, &error)) {
386+
if (FAILURE == phar_get_archive(&phar, ZSTR_VAL(resource->host), ZSTR_LEN(resource->host), NULL, &error)) {
387387
php_stream_wrapper_log_error(wrapper, options, "phar error: cannot create directory \"%s\" in phar \"%s\", error retrieving phar information: %s", ZSTR_VAL(resource->path) + 1, ZSTR_VAL(resource->host), error);
388388
efree(error);
389389
php_url_free(resource);
@@ -481,7 +481,7 @@ int phar_wrapper_rmdir(php_stream_wrapper *wrapper, const char *url, int options
481481
return 0;
482482
}
483483

484-
if (FAILURE == phar_get_archive(&phar, arch, arch_len, NULL, 0, NULL)) {
484+
if (FAILURE == phar_get_archive(&phar, arch, arch_len, NULL, NULL)) {
485485
phar = NULL;
486486
}
487487

@@ -509,7 +509,7 @@ int phar_wrapper_rmdir(php_stream_wrapper *wrapper, const char *url, int options
509509
return 0;
510510
}
511511

512-
if (FAILURE == phar_get_archive(&phar, ZSTR_VAL(resource->host), ZSTR_LEN(resource->host), NULL, 0, &error)) {
512+
if (FAILURE == phar_get_archive(&phar, ZSTR_VAL(resource->host), ZSTR_LEN(resource->host), NULL, &error)) {
513513
php_stream_wrapper_log_error(wrapper, options, "phar error: cannot remove directory \"%s\" in phar \"%s\", error retrieving phar information: %s", ZSTR_VAL(resource->path)+1, ZSTR_VAL(resource->host), error);
514514
efree(error);
515515
php_url_free(resource);

ext/phar/func_interceptors.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ static zend_string* phar_get_name_for_relative_paths(zend_string *filename, bool
101101
/* fopen within phar, if :// is not in the url, then prepend phar://<archive>/ */
102102
/* retrieving a file defaults to within the current directory, so use this if possible */
103103
phar_archive_data *phar;
104-
if (FAILURE == phar_get_archive(&phar, arch, arch_len, NULL, 0, NULL)) {
104+
if (FAILURE == phar_get_archive(&phar, arch, arch_len, NULL, NULL)) {
105105
efree(arch);
106106
return NULL;
107107
}
@@ -496,7 +496,7 @@ static void phar_file_stat(const char *filename, size_t filename_length, int typ
496496
size_t arch_len;
497497
if (SUCCESS == phar_split_fname(ZSTR_VAL(fname), ZSTR_LEN(fname), &arch, &arch_len, NULL, 2, 0)) {
498498
/* fopen within phar, if :// is not in the url, then prepend phar://<archive>/ */
499-
zend_result has_archive = phar_get_archive(&phar, arch, arch_len, NULL, 0, NULL);
499+
zend_result has_archive = phar_get_archive(&phar, arch, arch_len, NULL, NULL);
500500
efree(arch);
501501
if (FAILURE == has_archive) {
502502
goto skip_phar;
@@ -736,7 +736,7 @@ PHP_FUNCTION(phar_is_file) /* {{{ */
736736

737737
/* fopen within phar, if :// is not in the url, then prepend phar://<archive>/ */
738738
/* retrieving a file within the current directory, so use this if possible */
739-
if (SUCCESS == phar_get_archive(&phar, arch, arch_len, NULL, 0, NULL)) {
739+
if (SUCCESS == phar_get_archive(&phar, arch, arch_len, NULL, NULL)) {
740740
phar_entry_info *etemp;
741741

742742
zend_string *entry = phar_fix_filepath(filename, filename_len, true);
@@ -794,7 +794,7 @@ PHP_FUNCTION(phar_is_link) /* {{{ */
794794

795795
/* fopen within phar, if :// is not in the url, then prepend phar://<archive>/ */
796796
/* retrieving a file within the current directory, so use this if possible */
797-
if (SUCCESS == phar_get_archive(&phar, arch, arch_len, NULL, 0, NULL)) {
797+
if (SUCCESS == phar_get_archive(&phar, arch, arch_len, NULL, NULL)) {
798798
phar_entry_info *etemp;
799799

800800
zend_string *entry = phar_fix_filepath(filename, filename_len, true);

0 commit comments

Comments
 (0)