mirror of
https://github.com/php/php-src.git
synced 2024-11-27 20:03:40 +08:00
add an open mode for the memory streams that allows the stream to take
ownership of the passed-in buffer
This commit is contained in:
parent
e3ba31e899
commit
f400f0e665
@ -27,6 +27,7 @@
|
||||
|
||||
#define TEMP_STREAM_DEFAULT 0
|
||||
#define TEMP_STREAM_READONLY 1
|
||||
#define TEMP_STREAM_TAKE_BUFFER 2
|
||||
|
||||
#define php_stream_memory_create(mode) _php_stream_memory_create((mode) STREAMS_CC TSRMLS_CC)
|
||||
#define php_stream_memory_create_rel(mode) _php_stream_memory_create((mode) STREAMS_REL_CC TSRMLS_CC)
|
||||
|
@ -237,7 +237,7 @@ PHPAPI php_stream *_php_stream_memory_open(int mode, char *buf, size_t length ST
|
||||
if ((stream = php_stream_memory_create_rel(mode)) != NULL) {
|
||||
ms = stream->abstract;
|
||||
|
||||
if (mode == TEMP_STREAM_READONLY) {
|
||||
if (mode == TEMP_STREAM_READONLY || mode == TEMP_STREAM_TAKE_BUFFER) {
|
||||
/* use the buffer directly */
|
||||
ms->data = buf;
|
||||
ms->fsize = length;
|
||||
|
Loading…
Reference in New Issue
Block a user