Skip to content

Commit 419f675

Browse files
committed
ext/tidy: refactor php_tidy_file_to_mem()
Pass zend_string* along
1 parent 4433986 commit 419f675

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

ext/tidy/tidy.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ static inline PHPTidyObj *php_tidy_fetch_object(zend_object *obj) {
114114
/* }}} */
115115

116116
/* {{{ ext/tidy prototypes */
117-
static zend_string *php_tidy_file_to_mem(const char *, bool);
117+
static zend_string *php_tidy_file_to_mem(const zend_string *, bool);
118118
static void tidy_object_free_storage(zend_object *);
119119
static zend_object *tidy_object_new_node(zend_class_entry *);
120120
static zend_object *tidy_object_new_doc(zend_class_entry *);
@@ -246,7 +246,7 @@ static void php_tidy_quick_repair(INTERNAL_FUNCTION_PARAMETERS, bool is_file)
246246
Z_PARAM_BOOL(use_include_path)
247247
ZEND_PARSE_PARAMETERS_END();
248248

249-
if (!(data = php_tidy_file_to_mem(ZSTR_VAL(arg1), use_include_path))) {
249+
if (!(data = php_tidy_file_to_mem(arg1, use_include_path))) {
250250
RETURN_FALSE;
251251
}
252252
} else {
@@ -328,12 +328,12 @@ static void php_tidy_quick_repair(INTERNAL_FUNCTION_PARAMETERS, bool is_file)
328328
tidyRelease(doc);
329329
}
330330

331-
static zend_string *php_tidy_file_to_mem(const char *filename, bool use_include_path)
331+
static zend_string *php_tidy_file_to_mem(const zend_string *filename, bool use_include_path)
332332
{
333333
php_stream *stream;
334334
zend_string *data = NULL;
335335

336-
if (!(stream = php_stream_open_wrapper(filename, "rb", (use_include_path ? USE_PATH : 0), NULL))) {
336+
if (!(stream = php_stream_open_wrapper(ZSTR_VAL(filename), "rb", (use_include_path ? USE_PATH : 0), NULL))) {
337337
return NULL;
338338
}
339339
if ((data = php_stream_copy_to_mem(stream, PHP_STREAM_COPY_ALL, 0)) == NULL) {
@@ -1050,7 +1050,7 @@ PHP_FUNCTION(tidy_parse_file)
10501050
Z_PARAM_BOOL(use_include_path)
10511051
ZEND_PARSE_PARAMETERS_END();
10521052

1053-
if (!(contents = php_tidy_file_to_mem(ZSTR_VAL(inputfile), use_include_path))) {
1053+
if (!(contents = php_tidy_file_to_mem(inputfile, use_include_path))) {
10541054
php_error_docref(NULL, E_WARNING, "Cannot load \"%s\" into memory%s", ZSTR_VAL(inputfile), (use_include_path) ? " (using include path)" : "");
10551055
RETURN_FALSE;
10561056
}
@@ -1330,7 +1330,7 @@ PHP_METHOD(tidy, __construct)
13301330
obj = Z_TIDY_P(ZEND_THIS);
13311331

13321332
if (inputfile) {
1333-
if (!(contents = php_tidy_file_to_mem(ZSTR_VAL(inputfile), use_include_path))) {
1333+
if (!(contents = php_tidy_file_to_mem(inputfile, use_include_path))) {
13341334
zend_throw_error(zend_ce_exception, "Cannot load \"%s\" into memory%s", ZSTR_VAL(inputfile), (use_include_path) ? " (using include path)" : "");
13351335
RETURN_THROWS();
13361336
}
@@ -1375,7 +1375,7 @@ PHP_METHOD(tidy, parseFile)
13751375

13761376
obj = Z_TIDY_P(ZEND_THIS);
13771377

1378-
if (!(contents = php_tidy_file_to_mem(ZSTR_VAL(inputfile), use_include_path))) {
1378+
if (!(contents = php_tidy_file_to_mem(inputfile, use_include_path))) {
13791379
php_error_docref(NULL, E_WARNING, "Cannot load \"%s\" into memory%s", ZSTR_VAL(inputfile), (use_include_path) ? " (using include path)" : "");
13801380
RETURN_FALSE;
13811381
}

0 commit comments

Comments
 (0)