Skip to content

Commit 8217e89

Browse files
committed
ext/phar: avoid redundant allocation by using zend_string for alias
1 parent e2f5327 commit 8217e89

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

ext/phar/dirstream.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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, ZSTR_VAL(arch), ZSTR_LEN(arch), NULL, 0, NULL)) {
358+
if (FAILURE == phar_get_archive(&phar, ZSTR_VAL(arch), ZSTR_LEN(arch), NULL, NULL)) {
359359
phar = NULL;
360360
}
361361

@@ -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, ZSTR_VAL(arch), ZSTR_LEN(arch), NULL, 0, NULL)) {
484+
if (FAILURE == phar_get_archive(&phar, ZSTR_VAL(arch), ZSTR_LEN(arch), NULL, NULL)) {
485485
phar = NULL;
486486
}
487487

ext/phar/func_interceptors.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ static zend_string* phar_get_name_for_relative_paths(zend_string *filename, bool
9999
/* fopen within phar, if :// is not in the url, then prepend phar://<archive>/ */
100100
/* retrieving a file defaults to within the current directory, so use this if possible */
101101
phar_archive_data *phar;
102-
if (FAILURE == phar_get_archive(&phar, ZSTR_VAL(arch), ZSTR_LEN(arch), NULL, 0, NULL)) {
102+
if (FAILURE == phar_get_archive(&phar, ZSTR_VAL(arch), ZSTR_LEN(arch), NULL, NULL)) {
103103
zend_string_release_ex(arch, false);
104104
return NULL;
105105
}
@@ -494,7 +494,7 @@ static void phar_file_stat(const char *filename, size_t filename_length, int typ
494494
zend_string *arch = phar_split_fname(ZSTR_VAL(fname), ZSTR_LEN(fname), NULL, 2, 0);
495495
if (arch) {
496496
/* fopen within phar, if :// is not in the url, then prepend phar://<archive>/ */
497-
zend_result has_archive = phar_get_archive(&phar, ZSTR_VAL(arch), ZSTR_LEN(arch), NULL, 0, NULL);
497+
zend_result has_archive = phar_get_archive(&phar, ZSTR_VAL(arch), ZSTR_LEN(arch), NULL, NULL);
498498
zend_string_release_ex(arch, false);
499499
if (FAILURE == has_archive) {
500500
goto skip_phar;
@@ -733,7 +733,7 @@ PHP_FUNCTION(phar_is_file) /* {{{ */
733733

734734
/* fopen within phar, if :// is not in the url, then prepend phar://<archive>/ */
735735
/* retrieving a file within the current directory, so use this if possible */
736-
zend_result has_archive = phar_get_archive(&phar, ZSTR_VAL(arch), ZSTR_LEN(arch), NULL, 0, NULL);
736+
zend_result has_archive = phar_get_archive(&phar, ZSTR_VAL(arch), ZSTR_LEN(arch), NULL, NULL);
737737
zend_string_release_ex(arch, false);
738738
if (has_archive == SUCCESS) {
739739
phar_entry_info *etemp;
@@ -790,7 +790,7 @@ PHP_FUNCTION(phar_is_link) /* {{{ */
790790

791791
/* fopen within phar, if :// is not in the url, then prepend phar://<archive>/ */
792792
/* retrieving a file within the current directory, so use this if possible */
793-
zend_result has_archive = phar_get_archive(&phar, ZSTR_VAL(arch), ZSTR_LEN(arch), NULL, 0, NULL);
793+
zend_result has_archive = phar_get_archive(&phar, ZSTR_VAL(arch), ZSTR_LEN(arch), NULL, NULL);
794794
zend_string_release_ex(arch, false);
795795
if (has_archive == SUCCESS) {
796796
phar_entry_info *etemp;

ext/phar/phar_object.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,8 +1071,8 @@ static const spl_other_handler phar_spl_foreign_handler = {
10711071
*/
10721072
PHP_METHOD(Phar, __construct)
10731073
{
1074-
char *fname, *alias = NULL, *error, *save_fname;
1075-
size_t fname_len, alias_len = 0;
1074+
char *fname, *error, *save_fname;
1075+
size_t fname_len;
10761076
bool is_data;
10771077
zend_long flags = SPL_FILE_DIR_SKIPDOTS|SPL_FILE_DIR_UNIXPATHS;
10781078
zend_long format = 0;
@@ -4414,7 +4414,7 @@ PHP_METHOD(PharFileInfo, __construct)
44144414
RETURN_THROWS();
44154415
}
44164416

4417-
if (phar_open_from_filename(ZSTR_VAL(arch), ZSTR_LEN(arch), NULL, 0, REPORT_ERRORS, &phar_data, &error) == FAILURE) {
4417+
if (phar_open_from_filename(ZSTR_VAL(arch), ZSTR_LEN(arch), NULL, REPORT_ERRORS, &phar_data, &error) == FAILURE) {
44184418
zend_string_release_ex(arch, false);
44194419
efree(entry);
44204420
if (error) {

ext/phar/util.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ zend_string *phar_find_in_include_path(zend_string *filename, phar_archive_data
308308
}
309309

310310
if (*ZSTR_VAL(filename) == '.') {
311-
if (FAILURE == phar_get_archive(&phar, ZSTR_VAL(arch), ZSTR_LEN(arch), NULL, 0, NULL)) {
311+
if (FAILURE == phar_get_archive(&phar, ZSTR_VAL(arch), ZSTR_LEN(arch), NULL, NULL)) {
312312
zend_string_release_ex(arch, false);
313313
return NULL;
314314
}

0 commit comments

Comments
 (0)