summaryrefslogtreecommitdiff
path: root/klm/lm/binary_format.cc
diff options
context:
space:
mode:
authorKenneth Heafield <github@kheafield.com>2012-09-11 14:23:39 +0100
committerKenneth Heafield <github@kheafield.com>2012-09-11 14:27:52 +0100
commit8882e9ebe158aef382bb5544559ef7f2a553db62 (patch)
treef0ed595a45df16ddd1ca7ba61bc4ac0ee22d2dfb /klm/lm/binary_format.cc
parent104e23dd0b0795abab4565228537438481dc5a5b (diff)
Update kenlm and build system
Diffstat (limited to 'klm/lm/binary_format.cc')
-rw-r--r--klm/lm/binary_format.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/klm/lm/binary_format.cc b/klm/lm/binary_format.cc
index a56e998e..fd841e59 100644
--- a/klm/lm/binary_format.cc
+++ b/klm/lm/binary_format.cc
@@ -200,10 +200,10 @@ void SeekPastHeader(int fd, const Parameters &params) {
util::SeekOrThrow(fd, TotalHeaderSize(params.counts.size()));
}
-uint8_t *SetupBinary(const Config &config, const Parameters &params, std::size_t memory_size, Backing &backing) {
+uint8_t *SetupBinary(const Config &config, const Parameters &params, uint64_t memory_size, Backing &backing) {
const uint64_t file_size = util::SizeFile(backing.file.get());
// The header is smaller than a page, so we have to map the whole header as well.
- std::size_t total_map = TotalHeaderSize(params.counts.size()) + memory_size;
+ std::size_t total_map = util::CheckOverflow(TotalHeaderSize(params.counts.size()) + memory_size);
if (file_size != util::kBadSize && static_cast<uint64_t>(file_size) < total_map)
UTIL_THROW(FormatLoadException, "Binary file has size " << file_size << " but the headers say it should be at least " << total_map);