From f400f0e665bb8a8cdc9b13c09be7d9cc1e03db9f Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Sun, 6 Feb 2005 21:41:36 +0000 Subject: [PATCH] add an open mode for the memory streams that allows the stream to take ownership of the passed-in buffer --- main/php_memory_streams.h | 1 + main/streams/memory.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/main/php_memory_streams.h b/main/php_memory_streams.h index 4af7745efe..1a9b9000d7 100644 --- a/main/php_memory_streams.h +++ b/main/php_memory_streams.h @@ -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) diff --git a/main/streams/memory.c b/main/streams/memory.c index a61bd6619e..a9b3f01cb8 100644 --- a/main/streams/memory.c +++ b/main/streams/memory.c @@ -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; -- 2.50.1