diff options
| author | Lars Knoll <lars.knoll@qt.io> | 2020-04-16 12:56:58 +0200 |
|---|---|---|
| committer | Lars Knoll <lars.knoll@qt.io> | 2020-05-10 11:31:50 +0200 |
| commit | babcabfbc899d5a72b282f8cf0b510840e91ba0e (patch) | |
| tree | d4e89b175401d8daa0ca83675ab6b2f24de109e7 /src/corelib/codecs/qtextcodec.cpp | |
| parent | a77b19a911c4d6c47c185a8e59ebbcec8b14bcca (diff) | |
Clean up state handling for ICU and iconv based codecs
Get rid of the hack for the FreeFunction and instead add a proper
function pointer to clear the data to the ConverterState struct.
Change-Id: I104aae1a4381c69f1a254713ec76e1aeaa862cdc
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/corelib/codecs/qtextcodec.cpp')
| -rw-r--r-- | src/corelib/codecs/qtextcodec.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp index 72c78445612..c221e51ecc7 100644 --- a/src/corelib/codecs/qtextcodec.cpp +++ b/src/corelib/codecs/qtextcodec.cpp @@ -343,10 +343,19 @@ static void setup() {} */ QTextCodec::ConverterState::~ConverterState() { - if (flags & FreeFunction) - (QTextCodecUnalignedPointer::decode(state_data))(this); - else if (d) - free(d); + clear(); +} + +void QTextCodec::ConverterState::clear() +{ + if (clearFn) + clearFn(this); + remainingChars = 0; + invalidChars = 0; + state_data[0] = 0; + state_data[1] = 0; + state_data[2] = 0; + state_data[3] = 0; } /*! |
