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:
Wez Furlong 2005-02-06 21:41:36 +00:00
parent e3ba31e899
commit f400f0e665
2 changed files with 2 additions and 1 deletions

View 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)

View 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;