if (NULL == platform_msg) {
return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Cannot prepare platform message");
}
+ // releases platform_msg
+ std::unique_ptr<std::remove_pointer<msg_struct_t*>::type, decltype(&msg_release_struct)>
+ platform_msg_ptr(&platform_msg, &msg_release_struct);
msg_struct_t send_opt = msg_create_struct(MSG_STRUCT_SENDOPT);
+ // releases send_opt
+ std::unique_ptr<std::remove_pointer<msg_struct_t*>::type, decltype(&msg_release_struct)>
+ send_opt_ptr(&send_opt, &msg_release_struct);
+
msg_set_bool_value(send_opt, MSG_SEND_OPT_SETTING_BOOL, false);
const int msg_id = msg_add_message(m_msg_handle, platform_msg, send_opt);
if (msg_id < MSG_SUCCESS) {
- msg_release_struct(&send_opt);
- msg_release_struct(&platform_msg);
return LogAndCreateResult(
ErrorCode::UNKNOWN_ERR, "Cannot add message to draft",
("Message(%p): Failed to add draft, error: %d", message.get(), msg_id));
message->setMessageStatus(MessageStatus::STATUS_DRAFT);
msg_struct_t msg_conv = msg_create_struct(MSG_STRUCT_CONV_INFO);
+ // releases msg_conv
+ std::unique_ptr<std::remove_pointer<msg_struct_t*>::type, decltype(&msg_release_struct)>
+ msg_conv_ptr(&msg_conv, &msg_release_struct);
msg_error_t err = msg_get_conversation(m_msg_handle, msg_id, msg_conv);
if (MSG_SUCCESS == err) {
int conversationId = 0;
const int inResponseTo = msgInfo->getInResponseTo();
message->setInResponseTo(inResponseTo);
- if (msg_release_struct(&platform_msg) != MSG_SUCCESS) {
- LoggerW("Platform message is already destroyed");
- }
- if (msg_release_struct(&msg_conv) != MSG_SUCCESS) {
- LoggerW("Platform message is already destroyed");
- }
- if (msg_release_struct(&send_opt) != MSG_SUCCESS) {
- LoggerW("Platform message is already destroyed");
- }
delete msgInfo;
return PlatformResult(ErrorCode::NO_ERROR);
}