]> granicus.if.org Git - php/commitdiff
add an open mode for the memory streams that allows the stream to take
authorWez Furlong <wez@php.net>
Sun, 6 Feb 2005 21:41:36 +0000 (21:41 +0000)
committerWez Furlong <wez@php.net>
Sun, 6 Feb 2005 21:41:36 +0000 (21:41 +0000)
ownership of the passed-in buffer

main/php_memory_streams.h
main/streams/memory.c

index 4af7745efe3226428a03816f0b3264ccd82a3b24..1a9b9000d793702c36083d7871f56198a33df82f 100644 (file)
@@ -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)
index a61bd6619ef8dbe81834cd236d314a059b8ef066..a9b3f01cb85db952b82341440c259b19ca702734 100644 (file)
@@ -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;