aboutsummaryrefslogtreecommitdiffstats
path: root/native/jni/src/dictionary.h
diff options
context:
space:
mode:
Diffstat (limited to 'native/jni/src/dictionary.h')
-rw-r--r--native/jni/src/dictionary.h11
1 files changed, 9 insertions, 2 deletions
diff --git a/native/jni/src/dictionary.h b/native/jni/src/dictionary.h
index 2c79527be..3b55e5de9 100644
--- a/native/jni/src/dictionary.h
+++ b/native/jni/src/dictionary.h
@@ -55,7 +55,12 @@ class Dictionary {
int getFrequency(const int32_t *word, int length) const;
bool isValidBigram(const int32_t *word1, int length1, const int32_t *word2, int length2) const;
- void *getDict() const { return (void *)mDict; }
+ void *getDict() const { // required to release dictionary buffer
+ return reinterpret_cast<void *>(const_cast<unsigned char *>(mDict));
+ }
+ void *getOffsetDict() const {
+ return reinterpret_cast<void *>(const_cast<unsigned char *>(mOffsetDict));
+ }
int getDictSize() const { return mDictSize; }
int getMmapFd() const { return mMmapFd; }
int getDictBufAdjust() const { return mDictBufAdjust; }
@@ -68,6 +73,7 @@ class Dictionary {
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(Dictionary);
const unsigned char *mDict;
+ const unsigned char *mOffsetDict;
// Used only for the mmap version of dictionary loading, but we use these as dummy variables
// also for the malloc version.
@@ -85,8 +91,9 @@ class Dictionary {
inline int Dictionary::wideStrLen(unsigned short *str) {
if (!str) return 0;
unsigned short *end = str;
- while (*end)
+ while (*end) {
end++;
+ }
return end - str;
}
} // namespace latinime