aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/imap/MCIMAPSession.cpp
diff options
context:
space:
mode:
authorGravatar Dmitry Isaikin <isaikin@corp.mail.ru>2016-02-03 14:03:58 +0300
committerGravatar Dmitry Isaikin <isaikin@corp.mail.ru>2016-02-03 14:12:05 +0300
commit5ba469e045e88217eedaa13cfb3ff27ac469617a (patch)
treec2a461cf4f0c079e8c08bd81bcbd76eb4d86dde4 /src/core/imap/MCIMAPSession.cpp
parent35bf8538ed83c4085eff072fc52faee047680d3e (diff)
Remove extra memory copying while fetching attachment
Diffstat (limited to 'src/core/imap/MCIMAPSession.cpp')
-rwxr-xr-xsrc/core/imap/MCIMAPSession.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/core/imap/MCIMAPSession.cpp b/src/core/imap/MCIMAPSession.cpp
index c2cf43e6..fc06f505 100755
--- a/src/core/imap/MCIMAPSession.cpp
+++ b/src/core/imap/MCIMAPSession.cpp
@@ -2634,6 +2634,10 @@ Data * IMAPSession::fetchMessage(String * folder, bool identifier_is_uid, uint32
return data;
}
+static void nstringDeallocator(char * bytes, unsigned int length) {
+ mailimap_nstring_free(bytes);
+};
+
Data * IMAPSession::fetchMessageAttachment(String * folder, bool identifier_is_uid,
uint32_t identifier, String * partID,
Encoding encoding, IMAPProgressCallback * progressCallback, ErrorCode * pError)
@@ -2693,10 +2697,10 @@ Data * IMAPSession::fetchMessageAttachment(String * folder, bool identifier_is_u
return NULL;
}
- data = Data::dataWithBytes(text, (unsigned int) text_length);
+ data = Data::data();
+ data->takeBytesOwnership(text, (unsigned int) text_length, nstringDeallocator);
data = data->decodedDataUsingEncoding(encoding);
- mailimap_nstring_free(text);
* pError = ErrorNone;
return data;