diff options
author | Olivier Tilloy <olivier@tilloy.net> | 2010-05-17 19:32:45 +0200 |
---|---|---|
committer | Olivier Tilloy <olivier@tilloy.net> | 2010-05-17 19:32:45 +0200 |
commit | 705f86b3d71160c90920bc665a9bbb2b8daf392c (patch) | |
tree | 02335e6edc0dc280689216b80fc61a5f62e30ae0 /src | |
parent | 65e13aae83c40b5e040b59ac40415b4f97d24bb1 (diff) | |
download | pyexiv2-705f86b3d71160c90920bc665a9bbb2b8daf392c.tar.gz |
Free the allocated memory when deleting an IptcTag.
Diffstat (limited to 'src')
-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 de53b94..3cdc2d5 100644 --- a/src/exiv2wrapper.cpp +++ b/src/exiv2wrapper.cpp @@ -633,7 +633,9 @@ const std::string ExifTag::getHumanValue() IptcTag::IptcTag(const std::string& key, Exiv2::IptcMetadata* data): _key(key) { - if (data != 0) + _from_data = (data != 0); + + if (_from_data) { _data = data; } @@ -664,6 +666,14 @@ IptcTag::IptcTag(const std::string& key, Exiv2::IptcMetadata* data): _key(key) } } +IptcTag::~IptcTag() +{ + if (!_from_data) + { + delete _data; + } +} + void IptcTag::setRawValues(const boost::python::list& values) { if (!_repeatable && (boost::python::len(values) > 1)) diff --git a/src/exiv2wrapper.hpp b/src/exiv2wrapper.hpp index 29c266b..13091dd 100644 --- a/src/exiv2wrapper.hpp +++ b/src/exiv2wrapper.hpp @@ -75,6 +75,8 @@ public: // Constructor IptcTag(const std::string& key, Exiv2::IptcMetadata* data=0); + ~IptcTag(); + void setRawValues(const boost::python::list& values); const std::string getKey(); @@ -90,6 +92,7 @@ public: private: Exiv2::IptcKey _key; + bool _from_data; // whether the tag is built from an existing IptcMetadata Exiv2::IptcMetadata* _data; // _data contains only data with _key std::string _type; std::string _name; |