mirror of
https://github.com/taglib/taglib.git
synced 2025-06-04 01:28:21 -04:00
fix memory leaks
git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/kdesupport/taglib@402891 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
This commit is contained in:
parent
abbf24ade7
commit
60f73eb537
@ -62,6 +62,11 @@ APE::Item::Item(const Item &item)
|
||||
d = new ItemPrivate(*item.d);
|
||||
}
|
||||
|
||||
APE::Item::~Item()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
Item &APE::Item::operator=(const Item &item)
|
||||
{
|
||||
delete d;
|
||||
|
@ -69,6 +69,11 @@ namespace TagLib {
|
||||
*/
|
||||
Item(const Item &item);
|
||||
|
||||
/*!
|
||||
* Destroys the item.
|
||||
*/
|
||||
virtual ~Item();
|
||||
|
||||
/*!
|
||||
* Copies the contents of \a item into this item.
|
||||
*/
|
||||
|
@ -11,6 +11,8 @@ INCLUDES = \
|
||||
-I$(top_srcdir)/taglib/mpeg \
|
||||
-I$(top_srcdir)/taglib/mpeg/id3v1 \
|
||||
-I$(top_srcdir)/taglib/mpeg/id3v2 \
|
||||
-I$(top_srcdir)/taglib/ogg \
|
||||
-I$(top_srcdir)/taglib/ogg/vorbis \
|
||||
-I$(top_srcdir)/taglib/bindings/c
|
||||
|
||||
LDADD = ../libtag.la
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include <tbytevector.h>
|
||||
#include <fileref.h>
|
||||
|
||||
#include <mpegfile.h>
|
||||
|
||||
@ -36,6 +37,9 @@
|
||||
|
||||
#include <id3v1tag.h>
|
||||
|
||||
#include <vorbisfile.h>
|
||||
#include <xiphcomment.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace TagLib;
|
||||
|
||||
@ -43,49 +47,66 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
// process the command line args
|
||||
|
||||
|
||||
for(int i = 1; i < argc; i++) {
|
||||
|
||||
cout << "******************** \"" << argv[i] << "\"********************" << endl;
|
||||
|
||||
MPEG::File f(argv[i]);
|
||||
FileRef file(argv[i]);
|
||||
|
||||
ID3v2::Tag *id3v2tag = f.ID3v2Tag();
|
||||
if(dynamic_cast<MPEG::File *>(file.file())) {
|
||||
MPEG::File *f = static_cast<MPEG::File *>(file.file());
|
||||
|
||||
if(id3v2tag) {
|
||||
ID3v2::Tag *id3v2tag = f->ID3v2Tag();
|
||||
|
||||
cout << "ID3v2."
|
||||
<< id3v2tag->header()->majorVersion()
|
||||
<< "."
|
||||
<< id3v2tag->header()->revisionNumber()
|
||||
<< ", "
|
||||
<< id3v2tag->header()->tagSize()
|
||||
<< " bytes in tag"
|
||||
<< endl;
|
||||
if(id3v2tag) {
|
||||
|
||||
cout << "ID3v2."
|
||||
<< id3v2tag->header()->majorVersion()
|
||||
<< "."
|
||||
<< id3v2tag->header()->revisionNumber()
|
||||
<< ", "
|
||||
<< id3v2tag->header()->tagSize()
|
||||
<< " bytes in tag"
|
||||
<< endl;
|
||||
|
||||
ID3v2::FrameList::ConstIterator it = id3v2tag->frameList().begin();
|
||||
for(; it != id3v2tag->frameList().end(); it++)
|
||||
cout << (*it)->frameID() << " - \"" << (*it)->toString() << "\"" << endl;
|
||||
}
|
||||
else
|
||||
cout << "file does not have a valid id3v2 tag" << endl;
|
||||
|
||||
cout << endl << "ID3v1" << endl;
|
||||
|
||||
ID3v1::Tag *id3v1tag = f->ID3v1Tag();
|
||||
|
||||
if(id3v1tag) {
|
||||
cout << "title - \"" << id3v1tag->title() << "\"" << endl;
|
||||
cout << "artist - \"" << id3v1tag->artist() << "\"" << endl;
|
||||
cout << "album - \"" << id3v1tag->album() << "\"" << endl;
|
||||
cout << "year - \"" << id3v1tag->year() << "\"" << endl;
|
||||
cout << "comment - \"" << id3v1tag->comment() << "\"" << endl;
|
||||
cout << "track - \"" << id3v1tag->track() << "\"" << endl;
|
||||
cout << "genre - \"" << id3v1tag->genre() << "\"" << endl;
|
||||
}
|
||||
else
|
||||
cout << "file does not have a valid id3v1 tag" << endl;
|
||||
|
||||
ID3v2::FrameList::ConstIterator it = id3v2tag->frameList().begin();
|
||||
for(; it != id3v2tag->frameList().end(); it++)
|
||||
cout << (*it)->frameID() << " - \"" << (*it)->toString() << "\"" << endl;
|
||||
}
|
||||
else
|
||||
cout << "file does not have a valid id3v2 tag" << endl;
|
||||
else if(dynamic_cast<Ogg::Vorbis::File *>(file.file())) {
|
||||
Ogg::Vorbis::File *f = static_cast<Ogg::Vorbis::File *>(file.file());
|
||||
Ogg::XiphComment *tag = f->tag();
|
||||
|
||||
cout << endl << "ID3v1" << endl;
|
||||
|
||||
ID3v1::Tag *id3v1tag = f.ID3v1Tag();
|
||||
|
||||
if(id3v1tag) {
|
||||
cout << "title - \"" << id3v1tag->title() << "\"" << endl;
|
||||
cout << "artist - \"" << id3v1tag->artist() << "\"" << endl;
|
||||
cout << "album - \"" << id3v1tag->album() << "\"" << endl;
|
||||
cout << "year - \"" << id3v1tag->year() << "\"" << endl;
|
||||
cout << "comment - \"" << id3v1tag->comment() << "\"" << endl;
|
||||
cout << "track - \"" << id3v1tag->track() << "\"" << endl;
|
||||
cout << "genre - \"" << id3v1tag->genre() << "\"" << endl;
|
||||
const Ogg::FieldListMap fields = tag->fieldListMap();
|
||||
for(Ogg::FieldListMap::ConstIterator it = fields.begin(); it != fields.end(); ++it) {
|
||||
cout << (*it).first << " -";
|
||||
StringList values = (*it).second;
|
||||
for(StringList::ConstIterator valueIt = values.begin(); valueIt != values.end(); ++valueIt)
|
||||
cout << " \"" << *valueIt << '"';
|
||||
cout << endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
cout << "file does not have a valid id3v1 tag" << endl;
|
||||
|
||||
|
||||
cout << endl;
|
||||
}
|
||||
}
|
||||
|
@ -54,6 +54,9 @@ public:
|
||||
~FilePrivate()
|
||||
{
|
||||
delete ID3v1Tag;
|
||||
delete APETag;
|
||||
delete tag;
|
||||
delete ID3v2Header;
|
||||
delete properties;
|
||||
}
|
||||
|
||||
@ -227,7 +230,7 @@ void MPC::File::remove(int tags)
|
||||
if(d->APETag)
|
||||
d->tag = d->APETag;
|
||||
else
|
||||
d->tag = d->APETag = new APE::Tag();
|
||||
d->tag = d->APETag = new APE::Tag;
|
||||
}
|
||||
|
||||
if(tags & ID3v2) {
|
||||
@ -242,7 +245,7 @@ void MPC::File::remove(int tags)
|
||||
if(d->ID3v1Tag)
|
||||
d->tag = d->ID3v1Tag;
|
||||
else
|
||||
d->tag = d->APETag = new APE::Tag();
|
||||
d->tag = d->APETag = new APE::Tag;
|
||||
}
|
||||
}
|
||||
|
||||
@ -284,7 +287,7 @@ void MPC::File::read(bool readProperties, Properties::ReadStyle /* propertiesSty
|
||||
if(d->hasAPE)
|
||||
d->tag = d->APETag;
|
||||
else
|
||||
d->tag = d->APETag = new APE::Tag();
|
||||
d->tag = d->APETag = new APE::Tag;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user