summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorWez Furlong <wez@php.net>2005-02-06 21:41:36 (GMT)
committerWez Furlong <wez@php.net>2005-02-06 21:41:36 (GMT)
commitf400f0e665bb8a8cdc9b13c09be7d9cc1e03db9f (patch)
tree1afea9423ca4b0c33bb0cfff23ba4cfbaae4c632 /main
parente3ba31e899b5b1e6cf639086e71b033c5bbb3725 (diff)
downloadphp-f400f0e665bb8a8cdc9b13c09be7d9cc1e03db9f.tar.gz
add an open mode for the memory streams that allows the stream to take
ownership of the passed-in buffer
Diffstat (limited to 'main')
-rw-r--r--main/php_memory_streams.h1
-rw-r--r--main/streams/memory.c2
2 files changed, 2 insertions, 1 deletions
diff --git a/main/php_memory_streams.h b/main/php_memory_streams.h
index 4af7745..1a9b900 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 a61bd66..a9b3f01 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;