Merge pull request #128 from StefanoD/master

Memory Leak Fix
This commit is contained in:
Nikolaos Ftylitakis 2019-08-14 12:18:02 +03:00 committed by GitHub
commit 98318bc6a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 44 additions and 19 deletions

View File

@ -209,6 +209,7 @@ SOURCES += $$PWD/CameraImageWrapper.cpp \
$$PWD/zxing/zxing/WriterException.cpp \
$$PWD/zxing/zxing/aztec/AztecReader.cpp \
$$PWD/zxing/zxing/aztec/AztecDetectorResult.cpp \
$$PWD/zxing/zxing/common/Counted.cpp \
$$PWD/zxing/zxing/common/StringUtils.cpp \
$$PWD/zxing/zxing/common/Str.cpp \
$$PWD/zxing/zxing/common/PerspectiveTransform.cpp \

View File

@ -0,0 +1,36 @@
#include "Counted.h"
namespace zxing {
Counted::Counted() :
count_(0)
{
}
Counted::~Counted()
{
}
Counted *Counted::retain()
{
count_++;
return this;
}
void Counted::release()
{
count_--;
if (count_ == 0) {
count_ = 0xDEADF001;
delete this;
}
}
int Counted::count() const
{
return count_;
}
}

View File

@ -27,28 +27,16 @@ class Counted {
private:
unsigned int count_;
public:
Counted() :
count_(0) {
}
virtual ~Counted() {
}
Counted *retain() {
count_++;
return this;
}
void release() {
count_--;
if (count_ == 0) {
count_ = 0xDEADF001;
delete this;
}
}
Counted();
virtual ~Counted();
Counted *retain();
void release();
/* return the current count for denugging purposes or similar */
int count() const {
return count_;
}
int count() const;
};
/* counting reference to reference-counted objects */