Skip to content

Commit b3551cc

Browse files
committed
streams: use type bool instead of type int
1 parent b35dbe4 commit b3551cc

File tree

5 files changed

+22
-22
lines changed

5 files changed

+22
-22
lines changed

ext/standard/streamsfuncs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1215,7 +1215,7 @@ PHP_FUNCTION(stream_context_create)
12151215
/* }}} */
12161216

12171217
/* {{{ streams filter functions */
1218-
static void apply_filter_to_stream(int append, INTERNAL_FUNCTION_PARAMETERS)
1218+
static void apply_filter_to_stream(bool append, INTERNAL_FUNCTION_PARAMETERS)
12191219
{
12201220
php_stream *stream;
12211221
char *filtername;

main/php_streams.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ PHPAPI zend_result _php_stream_copy_to_stream_ex(php_stream *src, php_stream *de
531531

532532
/* read all data from stream and put into a buffer. Caller must free buffer
533533
* when done. */
534-
PHPAPI zend_string *_php_stream_copy_to_mem(php_stream *src, size_t maxlen, int persistent STREAMS_DC);
534+
PHPAPI zend_string *_php_stream_copy_to_mem(php_stream *src, size_t maxlen, bool persistent STREAMS_DC);
535535
#define php_stream_copy_to_mem(src, maxlen, persistent) _php_stream_copy_to_mem((src), (maxlen), (persistent) STREAMS_CC)
536536

537537
/* output all data from a stream */

main/streams/filter.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ PHPAPI HashTable *_php_get_stream_filters_hash(void)
4343
PHPAPI int php_stream_filter_register_factory(const char *filterpattern, const php_stream_filter_factory *factory)
4444
{
4545
int ret;
46-
zend_string *str = zend_string_init_interned(filterpattern, strlen(filterpattern), 1);
46+
zend_string *str = zend_string_init_interned(filterpattern, strlen(filterpattern), true);
4747
ret = zend_hash_add_ptr(&stream_filters_hash, str, (void*)factory) ? SUCCESS : FAILURE;
48-
zend_string_release_ex(str, 1);
48+
zend_string_release_ex(str, true);
4949
return ret;
5050
}
5151

@@ -70,18 +70,18 @@ PHPAPI int php_stream_filter_register_factory_volatile(zend_string *filterpatter
7070

7171
PHPAPI php_stream_bucket *php_stream_bucket_new(const php_stream *stream, char *buf, size_t buflen, uint8_t own_buf, uint8_t buf_persistent)
7272
{
73-
int is_persistent = php_stream_is_persistent(stream);
73+
bool is_persistent = php_stream_is_persistent(stream);
7474
php_stream_bucket *bucket;
7575

7676
bucket = (php_stream_bucket*)pemalloc(sizeof(php_stream_bucket), is_persistent);
7777
bucket->next = bucket->prev = NULL;
7878

7979
if (is_persistent && !buf_persistent) {
8080
/* all data in a persistent bucket must also be persistent */
81-
bucket->buf = pemalloc(buflen, 1);
81+
bucket->buf = pemalloc(buflen, true);
8282
memcpy(bucket->buf, buf, buflen);
8383
bucket->buflen = buflen;
84-
bucket->own_buf = 1;
84+
bucket->own_buf = true;
8585
} else {
8686
bucket->buf = buf;
8787
bucket->buflen = buflen;
@@ -118,7 +118,7 @@ PHPAPI php_stream_bucket *php_stream_bucket_make_writeable(php_stream_bucket *bu
118118
memcpy(retval->buf, bucket->buf, retval->buflen);
119119

120120
retval->refcount = 1;
121-
retval->own_buf = 1;
121+
retval->own_buf = true;
122122

123123
php_stream_bucket_delref(bucket);
124124

@@ -134,14 +134,14 @@ PHPAPI int php_stream_bucket_split(php_stream_bucket *in, php_stream_bucket **le
134134
(*left)->buflen = length;
135135
memcpy((*left)->buf, in->buf, length);
136136
(*left)->refcount = 1;
137-
(*left)->own_buf = 1;
137+
(*left)->own_buf = true;
138138
(*left)->is_persistent = in->is_persistent;
139139

140140
(*right)->buflen = in->buflen - length;
141141
(*right)->buf = pemalloc((*right)->buflen, in->is_persistent);
142142
memcpy((*right)->buf, in->buf + length, (*right)->buflen);
143143
(*right)->refcount = 1;
144-
(*right)->own_buf = 1;
144+
(*right)->own_buf = true;
145145
(*right)->is_persistent = in->is_persistent;
146146

147147
return SUCCESS;
@@ -395,7 +395,7 @@ PHPAPI void _php_stream_filter_append(php_stream_filter_chain *chain, php_stream
395395
}
396396
}
397397

398-
PHPAPI int _php_stream_filter_flush(php_stream_filter *filter, int finish)
398+
PHPAPI int _php_stream_filter_flush(php_stream_filter *filter, bool finish)
399399
{
400400
php_stream_bucket_brigade brig_a = { NULL, NULL }, brig_b = { NULL, NULL }, *inp = &brig_a, *outp = &brig_b, *brig_temp;
401401
php_stream_bucket *bucket;
@@ -480,7 +480,7 @@ PHPAPI int _php_stream_filter_flush(php_stream_filter *filter, int finish)
480480
return SUCCESS;
481481
}
482482

483-
PHPAPI php_stream_filter *php_stream_filter_remove(php_stream_filter *filter, int call_dtor)
483+
PHPAPI php_stream_filter *php_stream_filter_remove(php_stream_filter *filter, bool call_dtor)
484484
{
485485
if (filter->prev) {
486486
filter->prev->next = filter->next;

main/streams/php_stream_filter_api.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ struct _php_stream_bucket {
4444
char *buf;
4545
size_t buflen;
4646
/* if non-zero, buf should be pefreed when the bucket is destroyed */
47-
uint8_t own_buf;
48-
uint8_t is_persistent;
47+
bool own_buf;
48+
bool is_persistent;
4949

5050
/* destroy this struct when refcount falls to zero */
5151
int refcount;
@@ -124,8 +124,8 @@ PHPAPI void _php_stream_filter_prepend(php_stream_filter_chain *chain, php_strea
124124
PHPAPI int php_stream_filter_prepend_ex(php_stream_filter_chain *chain, php_stream_filter *filter);
125125
PHPAPI void _php_stream_filter_append(php_stream_filter_chain *chain, php_stream_filter *filter);
126126
PHPAPI int php_stream_filter_append_ex(php_stream_filter_chain *chain, php_stream_filter *filter);
127-
PHPAPI int _php_stream_filter_flush(php_stream_filter *filter, int finish);
128-
PHPAPI php_stream_filter *php_stream_filter_remove(php_stream_filter *filter, int call_dtor);
127+
PHPAPI int _php_stream_filter_flush(php_stream_filter *filter, bool finish);
128+
PHPAPI php_stream_filter *php_stream_filter_remove(php_stream_filter *filter, bool call_dtor);
129129
PHPAPI void php_stream_filter_free(php_stream_filter *filter);
130130
PHPAPI php_stream_filter *_php_stream_filter_alloc(const php_stream_filter_ops *fops, void *abstract, uint8_t persistent STREAMS_DC);
131131
END_EXTERN_C()

main/streams/streams.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1529,7 +1529,7 @@ PHPAPI ssize_t _php_stream_passthru(php_stream * stream STREAMS_DC)
15291529
}
15301530

15311531

1532-
PHPAPI zend_string *_php_stream_copy_to_mem(php_stream *src, size_t maxlen, int persistent STREAMS_DC)
1532+
PHPAPI zend_string *_php_stream_copy_to_mem(php_stream *src, size_t maxlen, bool persistent STREAMS_DC)
15331533
{
15341534
ssize_t ret = 0;
15351535
char *ptr;
@@ -2023,16 +2023,16 @@ PHPAPI php_stream_wrapper *php_stream_locate_url_wrapper(const char *path, const
20232023
php_stream_wrapper *plain_files_wrapper = (php_stream_wrapper*)&php_plain_files_wrapper;
20242024

20252025
if (protocol) {
2026-
int localhost = 0;
2026+
bool localhost = false;
20272027

20282028
if (!strncasecmp(path, "file://localhost/", 17)) {
2029-
localhost = 1;
2029+
localhost = true;
20302030
}
20312031

20322032
#ifdef PHP_WIN32
2033-
if (localhost == 0 && path[n+3] != '\0' && path[n+3] != '/' && path[n+4] != ':') {
2033+
if (!localhost && path[n+3] != '\0' && path[n+3] != '/' && path[n+4] != ':') {
20342034
#else
2035-
if (localhost == 0 && path[n+3] != '\0' && path[n+3] != '/') {
2035+
if (!localhost && path[n+3] != '\0' && path[n+3] != '/') {
20362036
#endif
20372037
if (options & REPORT_ERRORS) {
20382038
php_error_docref(NULL, E_WARNING, "Remote host file access not supported, %s", path);
@@ -2043,7 +2043,7 @@ PHPAPI php_stream_wrapper *php_stream_locate_url_wrapper(const char *path, const
20432043
if (path_for_open) {
20442044
/* skip past protocol and :/, but handle windows correctly */
20452045
*path_for_open = (char*)path + n + 1;
2046-
if (localhost == 1) {
2046+
if (localhost) {
20472047
(*path_for_open) += 11;
20482048
}
20492049
while (*(++*path_for_open)=='/') {

0 commit comments

Comments
 (0)