unsigned int line_crlf:1;
unsigned int return_nolf_line:1;
unsigned int stream_size_passthrough:1; /* stream is parent's size */
+ unsigned int nonpersistent_buffers:1;
};
struct istream * ATTR_NOWARN_UNUSED_RESULT
stream->real_stream->return_nolf_line = set;
}
+void i_stream_set_persistent_buffers(struct istream *stream, bool set)
+{
+ do {
+ stream->real_stream->nonpersistent_buffers = !set;
+ stream = stream->real_stream->parent;
+ } while (stream != NULL);
+}
+
static void i_stream_update(struct istream_private *stream)
{
if (stream->parent == NULL)
/* within buffer */
stream->v_offset += count;
_stream->skip += count;
+ if (_stream->nonpersistent_buffers &&
+ _stream->skip == _stream->pos) {
+ _stream->skip = _stream->pos = 0;
+ _stream->buffer_size = 0;
+ i_free_and_null(_stream->w_buffer);
+ }
return;
}
/* Enable/disable i_stream[_read]_next_line() returning the last line if it
doesn't end with LF. */
void i_stream_set_return_partial_line(struct istream *stream, bool set);
+/* Change whether buffers are allocated persistently (default=TRUE). When not,
+ the memory usage is minimized by freeing the stream's buffers whenever they
+ become empty. */
+void i_stream_set_persistent_buffers(struct istream *stream, bool set);
/* Returns number of bytes read if read was ok, -1 if EOF or error, -2 if the
input buffer is full. */