diff --git a/src/BinaryDict.cpp b/src/BinaryDict.cpp index fcfa0109..2e3fbc33 100644 --- a/src/BinaryDict.cpp +++ b/src/BinaryDict.cpp @@ -117,8 +117,8 @@ BinaryDictPtr BinaryDict::NewFromFile(FILE* fp) { throw InvalidFormat("Invalid OpenCC binary dictionary (numValues)"); } // Key offset - size_t keyOffset; - unitsRead = fread(&keyOffset, sizeof(size_t), 1, fp); + long keyOffset; + unitsRead = fread(&keyOffset, sizeof(long), 1, fp); if (unitsRead != 1 || keyOffset >= offsetBound) { throw InvalidFormat("Invalid OpenCC binary dictionary (keyOffset)"); } @@ -126,8 +126,8 @@ BinaryDictPtr BinaryDict::NewFromFile(FILE* fp) { // Value offset std::vector values; for (size_t j = 0; j < numValues; j++) { - size_t valueOffset; - unitsRead = fread(&valueOffset, sizeof(size_t), 1, fp); + long valueOffset; + unitsRead = fread(&valueOffset, sizeof(long), 1, fp); if (unitsRead != 1 || valueOffset >= offsetBound) { throw InvalidFormat("Invalid OpenCC binary dictionary (valueOffset)"); } diff --git a/src/PhraseExtract.cpp b/src/PhraseExtract.cpp index 69c21bba..34c07a76 100644 --- a/src/PhraseExtract.cpp +++ b/src/PhraseExtract.cpp @@ -99,9 +99,9 @@ class PhraseExtract::DictType { } void BuildTrie() { - std::unordered_map key_item_id_map; + std::unordered_map key_item_id_map; marisa::Keyset keyset; - for (int i = 0; i < items.size(); i++) { + for (size_t i = 0; i < items.size(); i++) { const auto& key = items[i].first; key_item_id_map[key.ToString()] = i; keyset.push_back(key.CString(), key.ByteLength()); @@ -117,7 +117,7 @@ class PhraseExtract::DictType { if (it == key_item_id_map.end()) { throw ShouldNotBeHere(); } - int item_id = it->second; + size_t item_id = it->second; marisa_id_item_map[marisa_id] = item_id; } } @@ -127,7 +127,7 @@ class PhraseExtract::DictType { dict; std::vector items; marisa::Trie marisa_trie; - std::vector marisa_id_item_map; + std::vector marisa_id_item_map; }; using namespace internal;