diff options
author | Olivier Tilloy <olivier@tilloy.net> | 2010-05-18 09:03:21 +0200 |
---|---|---|
committer | Olivier Tilloy <olivier@tilloy.net> | 2010-05-18 09:03:21 +0200 |
commit | 7757719639bdac43ad7eba141e7a77642eebd621 (patch) | |
tree | 49167cf7f63f08fe16a137b8d8701860b3ff5c73 | |
parent | 705f86b3d71160c90920bc665a9bbb2b8daf392c (diff) | |
download | pyexiv2-7757719639bdac43ad7eba141e7a77642eebd621.tar.gz |
Free the allocated memory when deleting an XmpTag.
-rw-r--r-- | src/exiv2wrapper.cpp | 12 | ||||
-rw-r--r-- | src/exiv2wrapper.hpp | 3 |
2 files changed, 14 insertions, 1 deletions
diff --git a/src/exiv2wrapper.cpp b/src/exiv2wrapper.cpp index 3cdc2d5..646abd9 100644 --- a/src/exiv2wrapper.cpp +++ b/src/exiv2wrapper.cpp @@ -753,7 +753,9 @@ const boost::python::list IptcTag::getRawValues() XmpTag::XmpTag(const std::string& key, Exiv2::Xmpdatum* datum): _key(key) { - if (datum != 0) + _from_datum = (datum != 0); + + if (_from_datum) { _datum = datum; } @@ -784,6 +786,14 @@ XmpTag::XmpTag(const std::string& key, Exiv2::Xmpdatum* datum): _key(key) } } +XmpTag::~XmpTag() +{ + if (!_from_datum) + { + delete _datum; + } +} + void XmpTag::setTextValue(const std::string& value) { _datum->setValue(value); diff --git a/src/exiv2wrapper.hpp b/src/exiv2wrapper.hpp index 13091dd..50470f4 100644 --- a/src/exiv2wrapper.hpp +++ b/src/exiv2wrapper.hpp @@ -111,6 +111,8 @@ public: // Constructor XmpTag(const std::string& key, Exiv2::Xmpdatum* datum=0); + ~XmpTag(); + void setTextValue(const std::string& value); void setArrayValue(const boost::python::list& values); void setLangAltValue(const boost::python::dict& values); @@ -127,6 +129,7 @@ public: private: Exiv2::XmpKey _key; + bool _from_datum; // whether the tag is built from an existing Xmpdatum Exiv2::Xmpdatum* _datum; std::string _exiv2_type; std::string _type; |