Make dc_mimeparser_parse() return parser instead of modifying reference

Since dc_mimeparser_parse() called `dc_mimeparser_empty()' on passed reference
anyway, it makes more sense to create new instance of `dc_mimeparser_t' and
return it instead.

Previously, usage pattern was following:

 dc_mimeparser_new()
 dc_mimeparser_empty() // semantically no-op, called inside dc_mimeparser_parse

Now call to dc_mimeparser_empty() is avoided.
This commit is contained in:
Dmitry Bogatov
2019-08-26 18:36:59 +00:00
committed by Floris Bruynooghe
parent 21976b14a6
commit 8e4a01c98d
3 changed files with 24 additions and 21 deletions

View File

@@ -56,9 +56,8 @@ pub unsafe fn dc_receive_imf(
// we use mailmime_parse() through dc_mimeparser (both call mailimf_struct_multiple_parse()
// somewhen, I did not found out anything that speaks against this approach yet)
let mut mime_parser = dc_mimeparser_new(context);
let body = std::slice::from_raw_parts(imf_raw_not_terminated as *const u8, imf_raw_bytes);
dc_mimeparser_parse(&mut mime_parser, body);
let mut mime_parser = dc_mimeparser_parse(context, body);
if mime_parser.header.is_empty() {
// Error - even adding an empty record won't help as we do not know the message ID