Fixed memory leak
Old zxing issue 1795: https://code.google.com/p/zxing/issues/detail?id=1795
This commit is contained in:
@@ -24,8 +24,8 @@ using std::string;
|
|||||||
using zxing::common::CharacterSetECI;
|
using zxing::common::CharacterSetECI;
|
||||||
using zxing::IllegalArgumentException;
|
using zxing::IllegalArgumentException;
|
||||||
|
|
||||||
std::map<int, CharacterSetECI*> CharacterSetECI::VALUE_TO_ECI;
|
std::map<int, zxing::Ref<CharacterSetECI>> CharacterSetECI::VALUE_TO_ECI;
|
||||||
std::map<std::string, CharacterSetECI*> CharacterSetECI::NAME_TO_ECI;
|
std::map<std::string, zxing::Ref<CharacterSetECI>> CharacterSetECI::NAME_TO_ECI;
|
||||||
|
|
||||||
const bool CharacterSetECI::inited = CharacterSetECI::init_tables();
|
const bool CharacterSetECI::inited = CharacterSetECI::init_tables();
|
||||||
|
|
||||||
@@ -72,11 +72,12 @@ bool CharacterSetECI::init_tables() {
|
|||||||
CharacterSetECI::CharacterSetECI(int const* values,
|
CharacterSetECI::CharacterSetECI(int const* values,
|
||||||
char const* const* names)
|
char const* const* names)
|
||||||
: values_(values), names_(names) {
|
: values_(values), names_(names) {
|
||||||
|
zxing::Ref<CharacterSetECI> this_ref(this);
|
||||||
for(int const* values = values_; *values != -1; values++) {
|
for(int const* values = values_; *values != -1; values++) {
|
||||||
VALUE_TO_ECI[*values] = this;
|
VALUE_TO_ECI[*values] = this_ref;
|
||||||
}
|
}
|
||||||
for(char const* const* names = names_; *names; names++) {
|
for(char const* const* names = names_; *names; names++) {
|
||||||
NAME_TO_ECI[string(*names)] = this;
|
NAME_TO_ECI[string(*names)] = this_ref;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,10 +25,10 @@
|
|||||||
namespace zxing {
|
namespace zxing {
|
||||||
namespace common {
|
namespace common {
|
||||||
|
|
||||||
class CharacterSetECI {
|
class CharacterSetECI : public Counted {
|
||||||
private:
|
private:
|
||||||
static std::map<int, CharacterSetECI*> VALUE_TO_ECI;
|
static std::map<int, zxing::Ref<CharacterSetECI>> VALUE_TO_ECI;
|
||||||
static std::map<std::string, CharacterSetECI*> NAME_TO_ECI;
|
static std::map<std::string, zxing::Ref<CharacterSetECI>> NAME_TO_ECI;
|
||||||
static const bool inited;
|
static const bool inited;
|
||||||
static bool init_tables();
|
static bool init_tables();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user