diff options
author | Dmitry Stogov <dmitry@zend.com> | 2021-03-16 20:31:36 +0300 |
---|---|---|
committer | Dmitry Stogov <dmitry@zend.com> | 2021-03-16 20:31:36 +0300 |
commit | c732ab400af92c54eee47c487a56009f1d79dd5d (patch) | |
tree | 083d31748450932114a7667aae9235cde030efcb /sapi/phpdbg | |
parent | 9bbeb0555b6b842ebd44e08510ff3f3226237544 (diff) | |
download | php-git-c732ab400af92c54eee47c487a56009f1d79dd5d.tar.gz |
Change Zend Stream API to use zend_string* instead of char*.
This allows to eliminate re-calculation of string lenght and hash value.
See the detailed list of changes in UPGRADING.INTERNALS.
Diffstat (limited to 'sapi/phpdbg')
-rw-r--r-- | sapi/phpdbg/phpdbg_list.c | 17 | ||||
-rw-r--r-- | sapi/phpdbg/phpdbg_prompt.c | 5 |
2 files changed, 10 insertions, 12 deletions
diff --git a/sapi/phpdbg/phpdbg_list.c b/sapi/phpdbg/phpdbg_list.c index 0967e22f65..73f88d46a1 100644 --- a/sapi/phpdbg/phpdbg_list.c +++ b/sapi/phpdbg/phpdbg_list.c @@ -241,9 +241,9 @@ zend_op_array *phpdbg_compile_file(zend_file_handle *file, int type) { * as it may invalidate the file handle. */ if (zend_stream_fixup(file, &bufptr, &len) == FAILURE) { if (type == ZEND_REQUIRE) { - zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, file->filename); + zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, ZSTR_VAL(file->filename)); } else { - zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, file->filename); + zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, ZSTR_VAL(file->filename)); } return NULL; } @@ -279,22 +279,19 @@ zend_op_array *phpdbg_compile_file(zend_file_handle *file, int type) { } zend_op_array *phpdbg_init_compile_file(zend_file_handle *file, int type) { - char *filename = (char *)(file->opened_path ? ZSTR_VAL(file->opened_path) : file->filename); + zend_string *filename = file->opened_path ? file->opened_path : file->filename; char resolved_path_buf[MAXPATHLEN]; zend_op_array *op_array; phpdbg_file_source *dataptr; - if (VCWD_REALPATH(filename, resolved_path_buf)) { - filename = resolved_path_buf; + if (VCWD_REALPATH(ZSTR_VAL(filename), resolved_path_buf)) { + filename = zend_string_init(resolved_path_buf, strlen(resolved_path_buf), 0); if (file->opened_path) { zend_string_release(file->opened_path); - file->opened_path = zend_string_init(filename, strlen(filename), 0); + file->opened_path = filename; } else { - if (file->free_filename) { - efree((char *) file->filename); - } - file->free_filename = 0; + zend_string_release(file->filename); file->filename = filename; } } diff --git a/sapi/phpdbg/phpdbg_prompt.c b/sapi/phpdbg/phpdbg_prompt.c index 13026978bf..acdae17ce3 100644 --- a/sapi/phpdbg/phpdbg_prompt.c +++ b/sapi/phpdbg/phpdbg_prompt.c @@ -566,7 +566,8 @@ int phpdbg_compile(void) /* {{{ */ return FAILURE; } - if (php_stream_open_for_zend_ex(PHPDBG_G(exec), &fh, USE_PATH|STREAM_OPEN_FOR_INCLUDE) == SUCCESS && zend_stream_fixup(&fh, &buf, &len) == SUCCESS) { + zend_stream_init_filename(&fh, PHPDBG_G(exec)); + if (php_stream_open_for_zend_ex(&fh, USE_PATH|STREAM_OPEN_FOR_INCLUDE) == SUCCESS && zend_stream_fixup(&fh, &buf, &len) == SUCCESS) { CG(skip_shebang) = 1; PHPDBG_G(ops) = zend_compile_file(&fh, ZEND_INCLUDE); zend_destroy_file_handle(&fh); @@ -581,7 +582,7 @@ int phpdbg_compile(void) /* {{{ */ } else { phpdbg_error("compile", "type=\"openfailure\" context=\"%s\"", "Could not open file %s", PHPDBG_G(exec)); } - + zend_destroy_file_handle(&fh); return FAILURE; } /* }}} */ |