Commits

shuerhaaken committed 44d2265

use virtual destructors to avoid future memory leaks in derrived classes

Comments (0)

Files changed (12)

bindings/c/taginfo_c.cc

 void taginfo_info_free_strings() {
     if(!stringManagementEnabled)
         return;
-
+    
     for(List<char *>::Iterator it = strings.begin(); it != strings.end(); ++it)
         free(*it);
     strings.clear();

libtaginfo/flacinfo.cc

 
 
 FlacInfo::~FlacInfo() {
+    //std::cout << "FlacInfo dtor" << std::endl;
 }
 
 

libtaginfo/info.cc

 
 
 Info::~Info() {
+    //std::cout << "Info dtor" << std::endl;
     if(taglib_fileref)
         delete taglib_fileref;
     if(taglib_file)

libtaginfo/taginfo.h

             String get_genre(void) const;
             void   set_genre(const String new_genre);
             
-            bool get_has_image() const;
+            bool   get_has_image() const;
             
             String get_homepage(void) const;
             void   set_homepage(const String new_homepage);
             
-            bool get_is_compilation() const;
-            void set_is_compilation(bool compilation);
+            bool   get_is_compilation() const;
+            void   set_is_compilation(bool compilation);
             
             String get_original_artist(void) const;
             void   set_original_artist(const String new_artist);
             
-            int  get_playcount() const;
-            void set_playcount(int new_playcount);
+            int    get_playcount() const;
+            void   set_playcount(int new_playcount);
             
-            int  get_rating() const;
-            void set_rating(const int new_rating);
+            int    get_rating() const;
+            void   set_rating(const int new_rating);
             
             String get_title(void) const;
             void   set_title(const String new_title);
             
-            int  get_track_count() const;
-            void set_track_count(const int new_track_count);
+            int    get_track_count() const;
+            void   set_track_count(const int new_track_count);
             
-            int  get_track_number() const;
-            void set_track_number(const int new_track_number);
+            int    get_track_number() const;
+            void   set_track_number(const int new_track_number);
             
-            int  get_volume_count() const;
-            void set_volume_count(const int count);
+            int    get_volume_count() const;
+            void   set_volume_count(const int count);
             
-            int  get_volume_number() const;
-            void set_volume_number(const int number);
+            int    get_volume_number() const;
+            void   set_volume_number(const int number);
             
-            int  get_year() const;
-            void set_year(const int new_year);
+            int    get_year() const;
+            void   set_year(const int new_year);
             
-            //Audio properties access functions
+            //Audio properties
+            int    get_length_seconds() const;
+            int    get_bitrate() const;
+            int    get_channels() const;
+            int    get_samplerate() const;
             
-            int  get_length_seconds() const;
-            int  get_bitrate() const;
-            int  get_channels() const;
-            int  get_samplerate() const;
-           
             
             //Labels
-            
             StringList get_track_labels_list() const;
             void       set_track_labels_list(const StringList &new_track_labels_list);
             
             
             
             
-            ~Info();
+            virtual ~Info();
             
             /*!
              * Loads tags and properties from the Info object of a file.

libtaginfo/taginfo_apetags.h

             TagLib::APE::Tag * taglib_apetag;
             
         public:
-            ~ApeTagInfo();
+            virtual ~ApeTagInfo();
             
             virtual bool load(void);
             virtual bool save(void);
             //! Constructor for ApeInfo
             //! \param filename is the path to the media file
             ApeInfo(const String &filename = "");
-            ~ApeInfo();
+            virtual ~ApeInfo();
     };
     
     
             //! Constructor for MpcInfo
             //! \param filename is the path to the media file
             MpcInfo(const String &filename = "");
-            ~MpcInfo();
+            virtual ~MpcInfo();
     };
     
     
             //! Constructor for WavPackInfo
             //! \param filename is the path to the media file
             WavPackInfo(const String &filename = "");
-            ~WavPackInfo();
+            virtual ~WavPackInfo();
     };
 }
 

libtaginfo/taginfo_asftags.h

             //! Constructor for AsfInfo
             //! \param filename is the path to the media file
             AsfInfo(const String &filename = "");
-            ~AsfInfo();
+            virtual ~AsfInfo();
             
             virtual bool load(void);
             virtual bool save(void);

libtaginfo/taginfo_id3tags.h

             ID3v2::Tag * taglib_tagId3v2;
             
         public :
-            ~Id3Info();
+            virtual ~Id3Info();
             
             virtual bool load(void);
             virtual bool save();
             //! Constructor for AiffInfo
             //! \param filename is the path to the media file
             AiffInfo(const String &filename = "");
-            ~AiffInfo();
+            virtual ~AiffInfo();
     };
     
     /*!
             //! Constructor for Mp3Info
             //! \param filename is the path to the media file
             Mp3Info(const String &filename = "");
-            ~Mp3Info();
+            virtual ~Mp3Info();
     };
     
     /*!
             //! Constructor for TrueAudioInfo
             //! \param filename is the path to the media file
             TrueAudioInfo(const String &filename = "");
-            ~TrueAudioInfo();
+            virtual ~TrueAudioInfo();
     };
     
     
             //! Constructor for WaveInfo
             //! \param filename is the path to the media file
             WaveInfo(const String &filename = "");
-            ~WaveInfo();
+            virtual ~WaveInfo();
     };
 }
 

libtaginfo/taginfo_modtags.h

             Mod::Tag * taglib_tagMod;
             
         public :
-            ~ModTagInfo();
+            virtual ~ModTagInfo();
             
             virtual bool load(void);
             virtual bool save();
             //! Constructor for ModInfo
             //! \param filename is the path to the media file
             ModInfo(const String &filename = "");
-            ~ModInfo();
+            virtual ~ModInfo();
     };
     
     /*!
             //! Constructor for ItInfo
             //! \param filename is the path to the media file
             ItInfo(const String &filename = "");
-            ~ItInfo();
+            virtual ~ItInfo();
     };
     
     /*!
             //! Constructor for S3mInfo
             //! \param filename is the path to the media file
             S3mInfo(const String &filename = "");
-            ~S3mInfo();
+            virtual ~S3mInfo();
     };
     
     /*!
             //! Constructor for XmInfo
             //! \param filename is the path to the media file
             XmInfo(const String &filename = "");
-            ~XmInfo();
+            virtual ~XmInfo();
     };
    
 }

libtaginfo/taginfo_mp4tags.h

             //! Constructor for Mp4Info
             //! \param filename is the path to the media file
             Mp4Info(const String &filename = "");
-            ~Mp4Info();
+            virtual ~Mp4Info();
             
             virtual bool load(void);
             virtual bool save(void);

libtaginfo/taginfo_xiphtags.h

             Ogg::XiphComment * xiphcomment;
             
         public :
-            ~XiphInfo();
+            virtual ~XiphInfo();
             
             virtual bool load(void);
             virtual bool save(void);
             //! Constructor for FlacInfo
             //! \param filename is the path to the media file
             FlacInfo(const String &filename = "");
-            ~FlacInfo();
+            virtual ~FlacInfo();
             
             virtual bool load(void);
             
             //! Constructor for OggInfo
             //! \param filename is the path to the media file
             OggInfo(const String &filename = "");
-            ~OggInfo();
+            virtual ~OggInfo();
     };
     
     
             //! Constructor for SpeexInfo
             //! \param filename is the path to the media file
             SpeexInfo(const String &filename = "");
-            ~SpeexInfo();
+            virtual ~SpeexInfo();
     };
 }
 

libtaginfo/xiphinfo.cc

 
 
 XiphInfo::~XiphInfo() {
+    //std::cout << "XiphInfo dtor" << std::endl;
 }
 
 

tests/ctest_write/main.c

 int main(void)
 {
     TagInfo_Info *info;
-    
     char val[200] = TESTDIR "samples/sample.flac";
     const char* target = "/tmp/out_03.flac";
     const char* s = val;
+    //printf("##1\n");
     
     if(cp(s, target) < 0)
         return 1; //EXIT_FAILURE
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.