/* {{{ */
static size_t php_stream_memory_read(php_stream *stream, char *buf, size_t count TSRMLS_DC)
-{
+{
php_stream_memory_data *ms;
assert(stream != NULL);
/* {{{ */
static int php_stream_memory_close(php_stream *stream, int close_handle TSRMLS_DC)
-{
+{
php_stream_memory_data *ms;
assert(stream != NULL);
if (ms->data) {
efree(ms->data);
}
- ms->data = NULL;
- ms->fsize = 0;
- ms->fpos = 0;
+ efree(ms);
return 0;
}
/* }}} */
/* {{{ */
-static int php_stream_memory_flush(php_stream *stream TSRMLS_DC) {
+static int php_stream_memory_flush(php_stream *stream TSRMLS_DC) {
/* nothing to do here */
return 0;
}
/* {{{ */
static int php_stream_memory_cast(php_stream *stream, int castas, void **ret TSRMLS_DC)
-{
+{
return FAILURE;
}
/* }}} */
/* {{{ */
PHPAPI char *_php_stream_memory_get_buffer(php_stream *stream, size_t *length STREAMS_DC TSRMLS_DC)
-{
+{
php_stream_memory_data *ms;
assert(stream != NULL);
/* {{{ */
static size_t php_stream_temp_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC)
-{
+{
php_stream_temp_data *ts;
assert(stream != NULL);
/* {{{ */
static size_t php_stream_temp_read(php_stream *stream, char *buf, size_t count TSRMLS_DC)
-{
+{
php_stream_temp_data *ts;
assert(stream != NULL);
ret = php_stream_free(ts->innerstream, PHP_STREAM_FREE_CLOSE | (close_handle ? 0 : PHP_STREAM_FREE_PRESERVE_HANDLE));
efree(ts);
-
+
return ret;
}
/* }}} */
/* {{{ */
static int php_stream_temp_flush(php_stream *stream TSRMLS_DC)
-{
+{
php_stream_temp_data *ts;
assert(stream != NULL);
/* {{{ */
static int php_stream_temp_seek(php_stream *stream, off_t offset, int whence TSRMLS_DC)
-{
+{
php_stream_temp_data *ts;
assert(stream != NULL);
/* {{{ */
char *php_stream_temp_gets(php_stream *stream, char *buf, size_t maxlen TSRMLS_DC)
-{
+{
php_stream_temp_data *ts;
assert(stream != NULL);
/* {{{ */
static int php_stream_temp_cast(php_stream *stream, int castas, void **ret TSRMLS_DC)
-{
+{
php_stream_temp_data *ts;
php_stream *file;
size_t memsize;
if (ret == NULL) {
return FAILURE;
}
-
+
/* perform the conversion and then pass the request on to the innerstream */
membuf = php_stream_memory_get_buffer(ts->innerstream, &memsize);
file = php_stream_fopen_tmpfile();
php_stream_write(file, membuf, memsize);
pos = php_stream_tell(ts->innerstream);
-
+
php_stream_close(ts->innerstream);
ts->innerstream = file;
php_stream_seek(ts->innerstream, pos, SEEK_SET);
-
+
return php_stream_cast(ts->innerstream, castas, ret, 1);
}
/* }}} */
/* {{{ */
PHPAPI php_stream *_php_stream_temp_create(int mode, size_t max_memory_usage STREAMS_DC TSRMLS_DC)
-{
+{
php_stream_temp_data *self;
php_stream *stream;
/* {{{ */
PHPAPI php_stream *_php_stream_temp_open(int mode, size_t max_memory_usage, char *buf, size_t length STREAMS_DC TSRMLS_DC)
-{
+{
php_stream *stream;
php_stream_temp_data *ms;