From 133fdf6057e24ee6b9393445c8e0253a50509cd4 Mon Sep 17 00:00:00 2001 From: hj kim Date: Thu, 7 May 2020 17:15:03 +0900 Subject: [PATCH] Use auto keyword and remove METADATA_EDITOR_ERROR_OUT_OF_MEMORY for "new" keyword Change-Id: I595c96bade904e724dc1674fcae7a5f6ac15c459 --- src/metadata_editor.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/metadata_editor.cpp b/src/metadata_editor.cpp index f553a86..0d6f146 100755 --- a/src/metadata_editor.cpp +++ b/src/metadata_editor.cpp @@ -213,8 +213,7 @@ static int __ID3_setTwixFrameByName(metadata_editor_s* _metadata, TagLib::ID3v1: if (tag2->frameListMap()[frameID].isEmpty()) { metadata_editor_info("The frame %s does not exist. Creating", frameID); // This is a common frame type for textural frames except comment frame - TagLib::ID3v2::TextIdentificationFrame* fr = new TagLib::ID3v2::TextIdentificationFrame(frameID); - metadata_editor_retvm_if(fr == NULL, METADATA_EDITOR_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY"); + auto fr = new TagLib::ID3v2::TextIdentificationFrame(frameID); fr->setTextEncoding(TagLib::String::UTF8); fr->setText(TagLib::String(value, TagLib::String::UTF8)); @@ -291,8 +290,7 @@ static int __ID3_setFrameByName(metadata_editor_s* _metadata, TagLib::ID3v2::Tag if (tag2->frameListMap()[frameID].isEmpty()) { metadata_editor_info("The frame %s does not exist. Creating", frameID); // This is a common frame type for textural frames except comment frame - TagLib::ID3v2::TextIdentificationFrame* fr = new TagLib::ID3v2::TextIdentificationFrame(frameID); - metadata_editor_retvm_if(fr == NULL, METADATA_EDITOR_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY"); + auto fr = new TagLib::ID3v2::TextIdentificationFrame(frameID); fr->setTextEncoding(TagLib::String::UTF8); fr->setText(TagLib::String(value, TagLib::String::UTF8)); @@ -340,7 +338,7 @@ static int __ID3_getLyricsFrame(metadata_editor_s* _metadata, TagLib::ID3v2::Tag metadata_editor_info("The frame USLT exists"); TagLib::ID3v2::FrameList::Iterator it = lst.begin(); - TagLib::ID3v2::UnsynchronizedLyricsFrame* frame = static_cast(*it); + auto frame = static_cast(*it); TagLib::String str = frame->text(); bool isUTF = false; if (!str.isLatin1()) isUTF = true; @@ -371,8 +369,8 @@ static int __ID3_setTwixCommentFrame(metadata_editor_s* _metadata, TagLib::ID3v1 // If the comment frame is empty - create the frame and add it to the list if (tag2->frameListMap()["COMM"].isEmpty()) { metadata_editor_info("The frame COMM does not exist. Creating"); - TagLib::ID3v2::CommentsFrame* fr = new TagLib::ID3v2::CommentsFrame; - metadata_editor_retvm_if(fr == NULL, METADATA_EDITOR_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY"); + auto fr = new TagLib::ID3v2::CommentsFrame; + fr->setText(TagLib::String(value, TagLib::String::UTF8)); fr->setTextEncoding(TagLib::String::UTF8); tag2->addFrame(fr); @@ -409,8 +407,7 @@ static int __ID3_setLyricsFrame(metadata_editor_s* _metadata, TagLib::ID3v2::Tag if (lst.isEmpty()) { // No lyrics - create the frame and add it to the ID3v2 tag metadata_editor_info("The frame USLT does not exist. Creating"); - TagLib::ID3v2::UnsynchronizedLyricsFrame* frame = new TagLib::ID3v2::UnsynchronizedLyricsFrame; - metadata_editor_retvm_if(frame == NULL, METADATA_EDITOR_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY"); + auto frame = new TagLib::ID3v2::UnsynchronizedLyricsFrame; frame->setTextEncoding(TagLib::String::UTF8); frame->setText(TagLib::String(value, TagLib::String::UTF8)); @@ -418,7 +415,7 @@ static int __ID3_setLyricsFrame(metadata_editor_s* _metadata, TagLib::ID3v2::Tag } else { // the lyrics frames exist - change the existing one metadata_editor_info("USLT frames exist in file. Changing"); TagLib::ID3v2::FrameList::Iterator it = lst.begin(); - TagLib::ID3v2::UnsynchronizedLyricsFrame* frame = static_cast(*it); + auto frame = static_cast(*it); frame->setTextEncoding(TagLib::String::UTF8); frame->setText(TagLib::String(value, TagLib::String::UTF8)); } -- 2.34.1