Make EncodingMapper singleton "new-less"

Use the modern way to code Singleton to get rid of the allocation memory.

Close #6031, close #6019
This commit is contained in:
wjx0912 2019-08-08 09:50:17 +08:00 committed by Don HO
parent d269fda5b2
commit fc9dfc86fc
No known key found for this signature in database
GPG Key ID: 6C429F1D8D84F46E
2 changed files with 4 additions and 4 deletions

View File

@ -83,8 +83,6 @@ static EncodingUnit encodings[] = {
{20866, "koi8_r csKOI8R"} //IDM_FORMAT_KOI8R_CYRILLIC
};
EncodingMapper * EncodingMapper::_pSelf = new EncodingMapper;
bool isInListA(const char *token, const char *list) {
if ((!token) || (!list))
return false;

View File

@ -35,7 +35,10 @@ struct EncodingUnit {
class EncodingMapper {
public:
static EncodingMapper * getInstance() {return _pSelf;};
static EncodingMapper * getInstance() {
static EncodingMapper _pSelf;
return &_pSelf;
};
int getEncodingFromIndex(int index) const;
int getIndexFromEncoding(int encoding) const;
int getEncodingFromString(const char * encodingAlias) const;
@ -43,7 +46,6 @@ public:
private:
EncodingMapper(){};
~EncodingMapper(){};
static EncodingMapper *_pSelf;
EncodingUnit* _encodings = nullptr;
};