dovecot-2.2: lib-storage: Small code cleanup for index_mail_get_...
dovecot at dovecot.org
dovecot at dovecot.org
Thu Apr 23 10:28:52 UTC 2015
details: http://hg.dovecot.org/dovecot-2.2/rev/de2023e630cb
changeset: 18451:de2023e630cb
user: Timo Sirainen <tss at iki.fi>
date: Thu Apr 23 13:27:17 2015 +0300
description:
lib-storage: Small code cleanup for index_mail_get_binary_stream()
stream_r is always non-NULL here. Also move unreferencing cache istream to
be last in case it might fix data.stream=NULL being here in some situations.
diffstat:
src/lib-storage/index/index-mail-binary.c | 23 ++++++++++-------------
1 files changed, 10 insertions(+), 13 deletions(-)
diffs (37 lines):
diff -r c3acdfc64a0b -r de2023e630cb src/lib-storage/index/index-mail-binary.c
--- a/src/lib-storage/index/index-mail-binary.c Thu Apr 23 13:01:50 2015 +0300
+++ b/src/lib-storage/index/index-mail-binary.c Thu Apr 23 13:27:17 2015 +0300
@@ -571,23 +571,20 @@
}
*size_r = cache->size;
*binary_r = binary;
- if (stream_r != NULL) {
- i_stream_ref(cache->input);
- *stream_r = cache->input;
- }
if (!converted) {
/* don't keep this cached. it's exactly the same as
the original stream */
+ i_assert(mail->data.stream != NULL);
+ i_stream_seek(mail->data.stream, part->physical_pos +
+ (include_hdr ? 0 :
+ part->header_size.physical_size));
+ input = i_stream_create_crlf(mail->data.stream);
+ *stream_r = i_stream_create_limit(input, *size_r);
+ i_stream_unref(&input);
mail_storage_free_binary_cache(_mail->box->storage);
- if (stream_r != NULL) {
- i_stream_unref(stream_r);
- i_stream_seek(mail->data.stream, part->physical_pos +
- (include_hdr ? 0 :
- part->header_size.physical_size));
- input = i_stream_create_crlf(mail->data.stream);
- *stream_r = i_stream_create_limit(input, *size_r);
- i_stream_unref(&input);
- }
+ } else {
+ *stream_r = cache->input;
+ i_stream_ref(cache->input);
}
return 0;
}
More information about the dovecot-cvs
mailing list