Skip to content

Commit f400f0e

Browse files
committed
add an open mode for the memory streams that allows the stream to take
ownership of the passed-in buffer
1 parent e3ba31e commit f400f0e

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

main/php_memory_streams.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
#define TEMP_STREAM_DEFAULT 0
2929
#define TEMP_STREAM_READONLY 1
30+
#define TEMP_STREAM_TAKE_BUFFER 2
3031

3132
#define php_stream_memory_create(mode) _php_stream_memory_create((mode) STREAMS_CC TSRMLS_CC)
3233
#define php_stream_memory_create_rel(mode) _php_stream_memory_create((mode) STREAMS_REL_CC TSRMLS_CC)

main/streams/memory.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ PHPAPI php_stream *_php_stream_memory_open(int mode, char *buf, size_t length ST
237237
if ((stream = php_stream_memory_create_rel(mode)) != NULL) {
238238
ms = stream->abstract;
239239

240-
if (mode == TEMP_STREAM_READONLY) {
240+
if (mode == TEMP_STREAM_READONLY || mode == TEMP_STREAM_TAKE_BUFFER) {
241241
/* use the buffer directly */
242242
ms->data = buf;
243243
ms->fsize = length;

0 commit comments

Comments
 (0)