Skip to content

Commit 17b8706

Browse files
committed
streams: add const specifier
1 parent ef98a6e commit 17b8706

File tree

6 files changed

+22
-22
lines changed

6 files changed

+22
-22
lines changed

ext/standard/streamsfuncs.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -568,13 +568,13 @@ PHP_FUNCTION(stream_get_meta_data)
568568
/* {{{ Retrieves list of registered socket transports */
569569
PHP_FUNCTION(stream_get_transports)
570570
{
571-
HashTable *stream_xport_hash;
572-
zend_string *stream_xport;
573571

574572
ZEND_PARSE_PARAMETERS_NONE();
575573

576-
stream_xport_hash = php_stream_xport_get_hash();
577574
array_init(return_value);
575+
576+
const HashTable *stream_xport_hash = php_stream_xport_get_hash();
577+
zend_string *stream_xport;
578578
ZEND_HASH_MAP_FOREACH_STR_KEY(stream_xport_hash, stream_xport) {
579579
add_next_index_str(return_value, zend_string_copy(stream_xport));
580580
} ZEND_HASH_FOREACH_END();
@@ -584,13 +584,12 @@ PHP_FUNCTION(stream_get_transports)
584584
/* {{{ Retrieves list of registered stream wrappers */
585585
PHP_FUNCTION(stream_get_wrappers)
586586
{
587-
HashTable *url_stream_wrappers_hash;
588-
zend_string *stream_protocol;
589-
590587
ZEND_PARSE_PARAMETERS_NONE();
591588

592-
url_stream_wrappers_hash = php_stream_get_url_stream_wrappers_hash();
593589
array_init(return_value);
590+
591+
const HashTable *url_stream_wrappers_hash = php_stream_get_url_stream_wrappers_hash();
592+
zend_string *stream_protocol;
594593
ZEND_HASH_MAP_FOREACH_STR_KEY(url_stream_wrappers_hash, stream_protocol) {
595594
if (stream_protocol) {
596595
add_next_index_str(return_value, zend_string_copy(stream_protocol));
@@ -882,7 +881,7 @@ static void user_space_stream_notifier_dtor(php_stream_notifier *notifier)
882881
notifier->ptr = NULL;
883882
}
884883

885-
static zend_result parse_context_options(php_stream_context *context, HashTable *options)
884+
static zend_result parse_context_options(php_stream_context *context, const HashTable *options)
886885
{
887886
zval *wval, *oval;
888887
zend_string *wkey, *okey;
@@ -906,7 +905,7 @@ static zend_result parse_context_options(php_stream_context *context, HashTable
906905
return SUCCESS;
907906
}
908907

909-
static zend_result parse_context_params(php_stream_context *context, HashTable *params)
908+
static zend_result parse_context_params(php_stream_context *context, const HashTable *params)
910909
{
911910
zval *tmp;
912911

main/php_streams.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ PHPAPI int _php_stream_seek(php_stream *stream, zend_off_t offset, int whence);
361361
#define php_stream_rewind(stream) _php_stream_seek((stream), 0L, SEEK_SET)
362362
#define php_stream_seek(stream, offset, whence) _php_stream_seek((stream), (offset), (whence))
363363

364-
PHPAPI zend_off_t _php_stream_tell(php_stream *stream);
364+
PHPAPI zend_off_t _php_stream_tell(const php_stream *stream);
365365
#define php_stream_tell(stream) _php_stream_tell((stream))
366366

367367
PHPAPI ssize_t _php_stream_read(php_stream *stream, char *buf, size_t count);

main/streams/filter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ PHPAPI int php_stream_filter_register_factory_volatile(zend_string *filterpatter
6868

6969
/* Buckets */
7070

71-
PHPAPI php_stream_bucket *php_stream_bucket_new(php_stream *stream, char *buf, size_t buflen, uint8_t own_buf, uint8_t buf_persistent)
71+
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
{
7373
int is_persistent = php_stream_is_persistent(stream);
7474
php_stream_bucket *bucket;

main/streams/php_stream_context.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ BEGIN_EXTERN_C()
5959
PHPAPI int php_le_stream_context(void);
6060
PHPAPI void php_stream_context_free(php_stream_context *context);
6161
PHPAPI php_stream_context *php_stream_context_alloc(void);
62-
PHPAPI zval *php_stream_context_get_option(php_stream_context *context,
62+
PHPAPI zval *php_stream_context_get_option(const php_stream_context *context,
6363
const char *wrappername, const char *optionname);
6464
PHPAPI void php_stream_context_set_option(php_stream_context *context,
6565
const char *wrappername, const char *optionname, zval *optionvalue);

main/streams/php_stream_filter_api.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ typedef enum {
6363

6464
/* Buckets API. */
6565
BEGIN_EXTERN_C()
66-
PHPAPI php_stream_bucket *php_stream_bucket_new(php_stream *stream, char *buf, size_t buflen, uint8_t own_buf, uint8_t buf_persistent);
66+
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);
6767
PHPAPI int php_stream_bucket_split(php_stream_bucket *in, php_stream_bucket **left, php_stream_bucket **right, size_t length);
6868
PHPAPI void php_stream_bucket_delref(php_stream_bucket *bucket);
6969
#define php_stream_bucket_addref(bucket) (bucket)->refcount++

main/streams/streams.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,12 +1041,13 @@ PHPAPI char *_php_stream_get_line(php_stream *stream, char *buf, size_t maxlen,
10411041
#define STREAM_BUFFERED_AMOUNT(stream) \
10421042
((size_t)(((stream)->writepos) - (stream)->readpos))
10431043

1044-
static const char *_php_stream_search_delim(php_stream *stream,
1045-
size_t maxlen,
1046-
size_t skiplen,
1047-
const char *delim, /* non-empty! */
1048-
size_t delim_len)
1049-
{
1044+
static const char *_php_stream_search_delim(
1045+
const php_stream *stream,
1046+
size_t maxlen,
1047+
size_t skiplen,
1048+
const char *delim, /* non-empty! */
1049+
size_t delim_len
1050+
) {
10501051
size_t seek_len;
10511052

10521053
/* set the maximum number of bytes we're allowed to read from buffer */
@@ -1340,7 +1341,7 @@ PHPAPI ssize_t _php_stream_printf(php_stream *stream, const char *fmt, ...)
13401341
return count;
13411342
}
13421343

1343-
PHPAPI zend_off_t _php_stream_tell(php_stream *stream)
1344+
PHPAPI zend_off_t _php_stream_tell(const php_stream *stream)
13441345
{
13451346
return stream->position;
13461347
}
@@ -1975,7 +1976,7 @@ PHPAPI zend_result php_unregister_url_stream_wrapper_volatile(zend_string *proto
19751976
/* {{{ php_stream_locate_url_wrapper */
19761977
PHPAPI php_stream_wrapper *php_stream_locate_url_wrapper(const char *path, const char **path_for_open, int options)
19771978
{
1978-
HashTable *wrapper_hash = (FG(stream_wrappers) ? FG(stream_wrappers) : &url_stream_wrappers_hash);
1979+
const HashTable *wrapper_hash = (FG(stream_wrappers) ? FG(stream_wrappers) : &url_stream_wrappers_hash);
19791980
php_stream_wrapper *wrapper = NULL;
19801981
const char *p, *protocol = NULL;
19811982
size_t n = 0;
@@ -2416,7 +2417,7 @@ PHPAPI void php_stream_notification_free(php_stream_notifier *notifier)
24162417
efree(notifier);
24172418
}
24182419

2419-
PHPAPI zval *php_stream_context_get_option(php_stream_context *context,
2420+
PHPAPI zval *php_stream_context_get_option(const php_stream_context *context,
24202421
const char *wrappername, const char *optionname)
24212422
{
24222423
zval *wrapperhash;

0 commit comments

Comments
 (0)