catching bad alloc
This commit is contained in:
parent
829c70d320
commit
7f2a212c6a
@ -119,13 +119,14 @@ void Concordia::loadRAMIndexFromDisk() {
|
|||||||
if (boost::filesystem::exists(_getWordMapFilePath())
|
if (boost::filesystem::exists(_getWordMapFilePath())
|
||||||
&& boost::filesystem::exists(_getHashedIndexFilePath())
|
&& boost::filesystem::exists(_getHashedIndexFilePath())
|
||||||
&& boost::filesystem::exists(_getMarkersFilePath())) {
|
&& boost::filesystem::exists(_getMarkersFilePath())) {
|
||||||
|
try {
|
||||||
// reading index from file
|
// reading index from file
|
||||||
_T->clear();
|
_T->clear();
|
||||||
std::ifstream hashedIndexFile;
|
std::ifstream hashedIndexFile;
|
||||||
hashedIndexFile.open(
|
hashedIndexFile.open(
|
||||||
_getHashedIndexFilePath().c_str(), std::ios::in
|
_getHashedIndexFilePath().c_str(), std::ios::in
|
||||||
| std::ios::ate | std::ios::binary);
|
| std::ios::ate | std::ios::binary);
|
||||||
saidx_t hiFileSize = hashedIndexFile.tellg();
|
long hiFileSize = hashedIndexFile.tellg();
|
||||||
if (hiFileSize > 0) {
|
if (hiFileSize > 0) {
|
||||||
hashedIndexFile.seekg(0, std::ios::beg);
|
hashedIndexFile.seekg(0, std::ios::beg);
|
||||||
|
|
||||||
@ -161,6 +162,9 @@ void Concordia::loadRAMIndexFromDisk() {
|
|||||||
}
|
}
|
||||||
// generating suffix array
|
// generating suffix array
|
||||||
_SA = _index->generateSuffixArray(_T);
|
_SA = _index->generateSuffixArray(_T);
|
||||||
|
} catch (const std::bad_alloc&) {
|
||||||
|
throw ConcordiaException("Error allocating memory, probably out of memory.");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
throw ConcordiaException("Index corrupt: missing files");
|
throw ConcordiaException("Index corrupt: missing files");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user