Thread safety for ID3v1 genres
    Lukáš Lalinský 
    lalinsky at gmail.com
       
    Mon May  2 21:07:45 CEST 2011
    
    
  
2011/5/2 Lukáš Lalinský <lalinsky at gmail.com>:
> On Mon, May 2, 2011 at 1:27 PM, Stephen F. Booth <me at sbooth.org> wrote:
>> I still would suggest the patch above, because no C++ objects are
>> being created at static initialization time.
>
> I have no problem with the patch, the cost of creating the genre
> string objects is nothing compared to the rest of the tag parsing.
Thinking a bit more about it, I'd prefer something like this (because
of ID3v1::genreIndex):
diff --git a/taglib/mpeg/id3v1/id3v1genres.cpp
b/taglib/mpeg/id3v1/id3v1genres.cpp
index 7893c72..eba4c52 100644
--- a/taglib/mpeg/id3v1/id3v1genres.cpp
+++ b/taglib/mpeg/id3v1/id3v1genres.cpp
@@ -207,7 +207,7 @@ ID3v1::GenreMap ID3v1::genreMap()
 String ID3v1::genre(int i)
 {
   if(i >= 0 && i < genresSize)
-    return genres[i];
+    return genres[i] + String::null; // always make a copy
   return String::null;
 }
Lukas
    
    
More information about the taglib-devel
mailing list