Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3f675f70 authored by Jean Chalard's avatar Jean Chalard
Browse files

Fix a large native memory leak.

This leak was about 500k and would happen whenever a new binary
dictionary was opened/closed.

Bug: 6299535
Change-Id: I4fad5b4d9c556ca889f5ef62d9d083a2eff6346a
parent a7352c8d
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ namespace latinime {
class WordsPriorityQueuePool {
 public:
    WordsPriorityQueuePool(int mainQueueMaxWords, int subQueueMaxWords, int maxWordLength) {
        // Note: using placement new() requires the caller to call the destructor explicitly.
        mMasterQueue = new(mMasterQueueBuf) WordsPriorityQueue(mainQueueMaxWords, maxWordLength);
        for (int i = 0, subQueueBufOffset = 0;
                i < MULTIPLE_WORDS_SUGGESTION_MAX_WORDS * SUB_QUEUE_MAX_COUNT;
@@ -36,6 +37,11 @@ class WordsPriorityQueuePool {
    }

    virtual ~WordsPriorityQueuePool() {
        // Note: these explicit calls to the destructor match the calls to placement new() above.
        if (mMasterQueue) mMasterQueue->~WordsPriorityQueue();
        for (int i = 0; i < MULTIPLE_WORDS_SUGGESTION_MAX_WORDS * SUB_QUEUE_MAX_COUNT; ++i) {
            if (mSubQueues[i]) mSubQueues[i]->~WordsPriorityQueue();
        }
    }

    WordsPriorityQueue* getMasterQueue() {