Skip to content

Commit 90a48ad

Browse files
committed
streams: make php_stream_flush() a proper function
By turning the _-prefixed version into a static extended version
1 parent 16e1416 commit 90a48ad

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

main/php_streams.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,8 +377,7 @@ PHPAPI int php_stream_getc(php_stream *stream);
377377

378378
PHPAPI int php_stream_putc(php_stream *stream, int c);
379379

380-
PHPAPI int _php_stream_flush(php_stream *stream, int closing);
381-
#define php_stream_flush(stream) _php_stream_flush((stream), 0)
380+
PHPAPI int php_stream_flush(php_stream *stream);
382381

383382
PHPAPI int php_stream_sync(php_stream *stream, bool data_only);
384383

main/streams/streams.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ static int _php_stream_free_persistent(zval *zv, void *pStream)
249249
return le->ptr == pStream;
250250
}
251251

252+
static int php_stream_flush_ex(php_stream *stream, bool closing);
252253

253254
PHPAPI int php_stream_free(php_stream *stream, int close_options) /* {{{ */
254255
{
@@ -336,7 +337,7 @@ fprintf(stderr, "stream_free: %s:%p[%s] preserve_handle=%d release_cast=%d remov
336337

337338
if (stream->flags & PHP_STREAM_FLAG_WAS_WRITTEN || stream->writefilters.head) {
338339
/* make sure everything is saved */
339-
_php_stream_flush(stream, 1);
340+
php_stream_flush_ex(stream, true);
340341
}
341342

342343
/* If not called from the resource dtor, remove the stream from the resource list. */
@@ -1183,7 +1184,7 @@ static ssize_t php_stream_write_filtered(php_stream *stream, const char *buf, si
11831184
return consumed;
11841185
}
11851186

1186-
PHPAPI int _php_stream_flush(php_stream *stream, int closing)
1187+
static int php_stream_flush_ex(php_stream *stream, bool closing)
11871188
{
11881189
int ret = 0;
11891190

@@ -1200,6 +1201,10 @@ PHPAPI int _php_stream_flush(php_stream *stream, int closing)
12001201
return ret;
12011202
}
12021203

1204+
PHPAPI int php_stream_flush(php_stream *stream) {
1205+
return php_stream_flush_ex(stream, false);
1206+
}
1207+
12031208
PHPAPI ssize_t php_stream_write(php_stream *stream, const char *buf, size_t count)
12041209
{
12051210
ssize_t bytes;
@@ -1324,7 +1329,7 @@ PHPAPI int php_stream_seek(php_stream *stream, zend_off_t offset, int whence)
13241329
bool is_start_seeking = whence == SEEK_SET && offset == 0;
13251330

13261331
if (stream->writefilters.head) {
1327-
_php_stream_flush(stream, 0);
1332+
php_stream_flush(stream);
13281333
if (!php_stream_are_filters_seekable(stream->writefilters.head, is_start_seeking,
13291334
PHP_STREAM_FILTER_WRITE)) {
13301335
return -1;

0 commit comments

Comments
 (0)