Commits

shuerhaaken committed 72b8783

use TagLib::String in format function

Comments (0)

Files changed (5)

libtaginfo/apeinfo.cc

             
             if(changedflag & CHANGED_DATA_RATING) {
                 char* str;
-                
-                if(asprintf (&str, "%u", rating_to_popularity(rating)) >= 0) {
+                taglib_apetag->addValue(APE_TAG_RATING, format("%u", rating_to_popularity(rating)));
+                /*if(asprintf (&str, "%u", rating_to_popularity(rating)) >= 0) {
                     taglib_apetag->addValue(APE_TAG_RATING, str);
                     free (str);
                     str = NULL;
-                }
+                }*/
                 
                 if(asprintf (&str, "%u", playcount) >= 0) {
                     taglib_apetag->addValue("PLAY_COUNTER", str);

libtaginfo/asfinfo.cc

                 asf_tag->removeItem("WM/SharedUserRating");
                 int WMRatings[] = { 0, 0, 1, 25, 50, 75, 99 };
                 
-                asf_tag->setAttribute("WM/SharedUserRating", format("%i", WMRatings[ rating + 1 ]).c_str());
+                asf_tag->setAttribute("WM/SharedUserRating", format("%i", WMRatings[ rating + 1 ]));
             }
             // The Labels
             if(changedflag & CHANGED_TRACK_LABELS)

libtaginfo/flacinfo.cc

                 xiphcomment->addField("ALBUMARTIST", album_artist);
             
             if(changedflag & CHANGED_DATA_RATING) {
-                xiphcomment->addField("RATING", format("%u", rating_to_popularity(rating)).c_str());
-                xiphcomment->addField("PLAY_COUNTER", format("%u", playcount).c_str());
+                xiphcomment->addField("RATING", format("%u", rating_to_popularity(rating)));
+                xiphcomment->addField("PLAY_COUNTER", format("%u", playcount));
             }
             // The Labels
             if(changedflag & CHANGED_TRACK_LABELS)

libtaginfo/mp4info.cc

             }
             if(mp4_tag->itemListMap().contains("disk")) {
                 disk_string = format("%i/%i", mp4_tag->itemListMap()["disk"].toIntPair().first,
-                                           mp4_tag->itemListMap()["disk"].toIntPair().second).c_str();
+                                           mp4_tag->itemListMap()["disk"].toIntPair().second);
             }
             if(mp4_tag->itemListMap().contains("cpil")) {
                 is_compilation = mp4_tag->itemListMap()["cpil"].toBool();
                 mp4_tag->itemListMap()["cpil"] = TagLib::MP4::Item(is_compilation);
             if(changedflag & CHANGED_DATA_RATING) {
                 mp4_tag->itemListMap()["----:com.apple.iTunes:RATING" ] =
-                    TagLib::MP4::Item(format("%u", rating_to_popularity(rating)).c_str());
+                    TagLib::MP4::Item(format("%u", rating_to_popularity(rating)));
                 
                 mp4_tag->itemListMap()[ "----:com.apple.iTunes:PLAY_COUNTER" ] =
-                    TagLib::MP4::Item(format("%u", playcount).c_str());
+                    TagLib::MP4::Item(format("%u", playcount));
             }
             // The Labels
             if(changedflag & CHANGED_ARTIST_LABELS)

libtaginfo/taginfo_internal.h

 }
 
 
-inline string format(const char* fmt, ...) {
+inline String format(const char* fmt, ...) {
     char buffer[BUFFERSIZE] = {'\0'};
     va_list vl;
     va_start(vl, fmt);
     if(nsize < 0) {
         cout << "Error: String allocation failed in taginfo format function." << endl;
         va_end(vl);
-        string ret;
+        String ret = String("");
         return ret;
     }
     else {
         va_end(vl);
-        string ret(buffer);
+        String ret(buffer);
         return ret;
     }
 }