这个异常查了资料,据说是频繁的new和delet造成的,这个代码写的也是飘逸;
bool SpellingTrie::load_spl_trie(FILE *fp) {
if (NULL == fp)
return false;
if (fread(&spelling_size_, sizeof(size_t), 1, fp) != 1)
return false;
if (fread(&spelling_num_, sizeof(size_t), 1, fp) != 1)
return false;
if (fread(&score_amplifier_, sizeof(float), 1, fp) != 1)
return false;
if (fread(&average_score_, sizeof(unsigned char), 1, fp) != 1)
return false;
printf("%s","iii");
if (NULL != spelling_buf_)
delete [] spelling_buf_;
printf("%s","jjj");
spelling_buf_ = new char[spelling_size_ * spelling_num_];
printf("%s","kkk");
if (NULL == spelling_buf_)
return false;
printf("%s","lll");
if (fread(spelling_buf_, sizeof(char) * spelling_size_,
spelling_num_, fp) != spelling_num_)
return false;
return construct(spelling_buf_, spelling_size_, spelling_num_,
score_amplifier_, average_score_);
}