catching bad alloc

This commit is contained in:
Rafał Jaworski 2019-02-28 15:38:43 +01:00
parent 829c70d320
commit 7f2a212c6a

View File

@ -119,13 +119,14 @@ void Concordia::loadRAMIndexFromDisk() {
if (boost::filesystem::exists(_getWordMapFilePath())
&& boost::filesystem::exists(_getHashedIndexFilePath())
&& boost::filesystem::exists(_getMarkersFilePath())) {
try {
// reading index from file
_T->clear();
std::ifstream hashedIndexFile;
hashedIndexFile.open(
_getHashedIndexFilePath().c_str(), std::ios::in
| std::ios::ate | std::ios::binary);
saidx_t hiFileSize = hashedIndexFile.tellg();
long hiFileSize = hashedIndexFile.tellg();
if (hiFileSize > 0) {
hashedIndexFile.seekg(0, std::ios::beg);
@ -161,6 +162,9 @@ void Concordia::loadRAMIndexFromDisk() {
}
// generating suffix array
_SA = _index->generateSuffixArray(_T);
} catch (const std::bad_alloc&) {
throw ConcordiaException("Error allocating memory, probably out of memory.");
}
} else {
throw ConcordiaException("Index corrupt: missing files");
}