mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2024-11-27 12:49:35 +08:00
commit
7b5b16779a
@ -830,8 +830,7 @@ int TessBaseAPI::Recognize(ETEXT_DESC* monitor) {
|
||||
return -1;
|
||||
if (FindLines() != 0)
|
||||
return -1;
|
||||
if (page_res_ != NULL)
|
||||
delete page_res_;
|
||||
delete page_res_;
|
||||
if (block_list_->empty()) {
|
||||
page_res_ = new PAGE_RES(false, block_list_,
|
||||
&tesseract_->prev_word_best_choice_);
|
||||
|
@ -373,8 +373,7 @@ class TESS_API TessBaseAPI {
|
||||
* delete it when it it is replaced or the API is destructed.
|
||||
*/
|
||||
void SetThresholder(ImageThresholder* thresholder) {
|
||||
if (thresholder_ != NULL)
|
||||
delete thresholder_;
|
||||
delete thresholder_;
|
||||
thresholder_ = thresholder;
|
||||
ClearResults();
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ const PageIterator& PageIterator::operator=(const PageIterator& src) {
|
||||
rect_top_ = src.rect_top_;
|
||||
rect_width_ = src.rect_width_;
|
||||
rect_height_ = src.rect_height_;
|
||||
if (it_ != NULL) delete it_;
|
||||
delete it_;
|
||||
it_ = new PAGE_RES_IT(*src.it_);
|
||||
BeginWord(src.blob_index_);
|
||||
return *this;
|
||||
@ -597,10 +597,8 @@ void PageIterator::BeginWord(int offset) {
|
||||
}
|
||||
word_ = NULL;
|
||||
// We will be iterating the box_word.
|
||||
if (cblob_it_ != NULL) {
|
||||
delete cblob_it_;
|
||||
cblob_it_ = NULL;
|
||||
}
|
||||
delete cblob_it_;
|
||||
cblob_it_ = NULL;
|
||||
} else {
|
||||
// No recognition yet, so a "symbol" is a cblob.
|
||||
word_ = word_res->word;
|
||||
|
@ -191,7 +191,7 @@ ScrollView* bln_word_window_handle() { // return handle
|
||||
*/
|
||||
|
||||
void build_image_window(int width, int height) {
|
||||
if (image_win != NULL) { delete image_win; }
|
||||
delete image_win;
|
||||
image_win = new ScrollView(editor_image_win_name.string(),
|
||||
editor_image_xpos, editor_image_ypos,
|
||||
width + 1,
|
||||
|
@ -51,7 +51,7 @@ class PDBLK {
|
||||
|
||||
/// destructor
|
||||
~PDBLK() {
|
||||
if (hand_poly) delete hand_poly;
|
||||
delete hand_poly;
|
||||
}
|
||||
|
||||
POLY_BLOCK *poly_block() const { return hand_poly; }
|
||||
|
@ -63,7 +63,7 @@ template<class T> class SmartPtr {
|
||||
return ptr_;
|
||||
}
|
||||
void reset(T* ptr) {
|
||||
if (ptr_ != NULL) delete ptr_;
|
||||
delete ptr_;
|
||||
ptr_ = ptr;
|
||||
}
|
||||
bool operator==(const T* ptr) const {
|
||||
|
@ -209,7 +209,7 @@ void TrainingSample::ExtractCharDesc(int int_feature_type,
|
||||
int geo_type,
|
||||
CHAR_DESC_STRUCT* char_desc) {
|
||||
// Extract the INT features.
|
||||
if (features_ != NULL) delete [] features_;
|
||||
delete [] features_;
|
||||
FEATURE_SET_STRUCT* char_features = char_desc->FeatureSets[int_feature_type];
|
||||
if (char_features == NULL) {
|
||||
tprintf("Error: no features to train on of type %s\n",
|
||||
@ -230,7 +230,7 @@ void TrainingSample::ExtractCharDesc(int int_feature_type,
|
||||
}
|
||||
}
|
||||
// Extract the Micro features.
|
||||
if (micro_features_ != NULL) delete [] micro_features_;
|
||||
delete [] micro_features_;
|
||||
char_features = char_desc->FeatureSets[micro_type];
|
||||
if (char_features == NULL) {
|
||||
tprintf("Error: no features to train on of type %s\n",
|
||||
|
@ -96,10 +96,8 @@ bool TrainingSampleSet::DeSerialize(bool swap, FILE* fp) {
|
||||
num_raw_samples_ = samples_.size();
|
||||
if (!unicharset_.load_from_file(fp)) return false;
|
||||
if (!font_id_map_.DeSerialize(swap, fp)) return false;
|
||||
if (font_class_array_ != NULL) {
|
||||
delete font_class_array_;
|
||||
font_class_array_ = NULL;
|
||||
}
|
||||
delete font_class_array_;
|
||||
font_class_array_ = NULL;
|
||||
inT8 not_null;
|
||||
if (fread(¬_null, sizeof(not_null), 1, fp) != 1) return false;
|
||||
if (not_null) {
|
||||
|
@ -40,9 +40,7 @@ void CharSampSet::Cleanup() {
|
||||
// only free samples if owned by class
|
||||
if (own_samples_ == true) {
|
||||
for (int samp_idx = 0; samp_idx < cnt_; samp_idx++) {
|
||||
if (samp_buff_[samp_idx] != NULL) {
|
||||
delete samp_buff_[samp_idx];
|
||||
}
|
||||
delete samp_buff_[samp_idx];
|
||||
}
|
||||
}
|
||||
delete []samp_buff_;
|
||||
|
@ -195,9 +195,7 @@ SearchNode *SearchColumn::AddNode(LangModEdge *edge, int reco_cost,
|
||||
}
|
||||
|
||||
// free the edge
|
||||
if (edge != NULL) {
|
||||
delete edge;
|
||||
}
|
||||
delete edge;
|
||||
}
|
||||
|
||||
// update Min and Max Costs
|
||||
|
@ -191,7 +191,7 @@ Dict::Dict(CCUtil *ccutil)
|
||||
|
||||
Dict::~Dict() {
|
||||
End();
|
||||
if (hyphen_word_ != NULL) delete hyphen_word_;
|
||||
delete hyphen_word_;
|
||||
if (output_ambig_words_file_ != NULL) fclose(output_ambig_words_file_);
|
||||
}
|
||||
|
||||
@ -360,10 +360,8 @@ void Dict::End() {
|
||||
dawgs_.clear();
|
||||
successors_.clear();
|
||||
document_words_ = NULL;
|
||||
if (pending_words_ != NULL) {
|
||||
delete pending_words_;
|
||||
pending_words_ = NULL;
|
||||
}
|
||||
delete pending_words_;
|
||||
pending_words_ = NULL;
|
||||
}
|
||||
|
||||
// Returns true if in light of the current state unichar_id is allowed
|
||||
|
@ -72,10 +72,8 @@ static ds_status releaseDSProfile(ds_profile* profile, ds_score_release sr) {
|
||||
if (profile->devices!=NULL && sr!=NULL) {
|
||||
unsigned int i;
|
||||
for (i = 0; i < profile->numDevices; i++) {
|
||||
if (profile->devices[i].oclDeviceName)
|
||||
free(profile->devices[i].oclDeviceName);
|
||||
if (profile->devices[i].oclDriverVersion)
|
||||
free(profile->devices[i].oclDriverVersion);
|
||||
free(profile->devices[i].oclDeviceName);
|
||||
free(profile->devices[i].oclDriverVersion);
|
||||
status = sr(profile->devices[i].score);
|
||||
if (status != DS_SUCCESS)
|
||||
break;
|
||||
@ -171,15 +169,14 @@ static ds_status initDSProfile(ds_profile** p, const char* version) {
|
||||
profile->version = version;
|
||||
|
||||
cleanup:
|
||||
if (platforms) free(platforms);
|
||||
if (devices) free(devices);
|
||||
free(platforms);
|
||||
free(devices);
|
||||
if (status == DS_SUCCESS) {
|
||||
*p = profile;
|
||||
}
|
||||
else {
|
||||
if (profile) {
|
||||
if (profile->devices)
|
||||
free(profile->devices);
|
||||
free(profile->devices);
|
||||
free(profile);
|
||||
}
|
||||
}
|
||||
@ -585,7 +582,7 @@ static ds_status readProfileFromFile(ds_profile* profile,
|
||||
}
|
||||
}
|
||||
cleanup:
|
||||
if (contentStart!=NULL) free(contentStart);
|
||||
free(contentStart);
|
||||
return status;
|
||||
}
|
||||
|
||||
|
@ -538,30 +538,19 @@ int OpenclDevice::GeneratBinFromKernelSource( cl_program program, const char * c
|
||||
// Release all resouces and memory
|
||||
for ( i = 0; i < numDevices; i++ )
|
||||
{
|
||||
if ( binaries[i] != NULL )
|
||||
{
|
||||
free( binaries[i] );
|
||||
binaries[i] = NULL;
|
||||
}
|
||||
free(binaries[i]);
|
||||
binaries[i] = NULL;
|
||||
}
|
||||
|
||||
if ( binaries != NULL )
|
||||
{
|
||||
free( binaries );
|
||||
binaries = NULL;
|
||||
}
|
||||
free( binaries );
|
||||
binaries = NULL;
|
||||
|
||||
if ( binarySizes != NULL )
|
||||
{
|
||||
free( binarySizes );
|
||||
binarySizes = NULL;
|
||||
}
|
||||
free(binarySizes);
|
||||
binarySizes = NULL;
|
||||
|
||||
if ( mpArryDevsID != NULL )
|
||||
{
|
||||
free( mpArryDevsID );
|
||||
mpArryDevsID = NULL;
|
||||
}
|
||||
free(mpArryDevsID);
|
||||
mpArryDevsID = NULL;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -259,8 +259,8 @@ void split_to_blob( //split the blob
|
||||
pitch_error,
|
||||
left_coutlines,
|
||||
right_coutlines);
|
||||
if (blob != NULL)
|
||||
delete blob; //free it
|
||||
|
||||
delete blob;
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
|
@ -507,8 +507,7 @@ void vigorous_noise_removal(TO_BLOCK* block) {
|
||||
continue; // Looks OK.
|
||||
}
|
||||
// It might be noise so get rid of it.
|
||||
if (blob->cblob() != NULL)
|
||||
delete blob->cblob();
|
||||
delete blob->cblob();
|
||||
delete b_it.extract();
|
||||
} else {
|
||||
prev = blob;
|
||||
|
@ -524,7 +524,7 @@ CLUSTERER *SetUpForClustering(const FEATURE_DEFS_STRUCT &FeatureDefs,
|
||||
}
|
||||
CharID++;
|
||||
}
|
||||
if ( Sample != NULL ) free( Sample );
|
||||
free( Sample );
|
||||
return( Clusterer );
|
||||
|
||||
} /* SetUpForClustering */
|
||||
|
@ -568,9 +568,7 @@ int Wordrec::select_blob_to_split(
|
||||
|
||||
for (x = 0; x < blob_choices.size(); ++x) {
|
||||
if (blob_choices[x] == NULL) {
|
||||
if (fragments != NULL) {
|
||||
delete[] fragments;
|
||||
}
|
||||
delete[] fragments;
|
||||
return x;
|
||||
} else {
|
||||
blob_choice = blob_choices[x];
|
||||
@ -614,9 +612,7 @@ int Wordrec::select_blob_to_split(
|
||||
}
|
||||
}
|
||||
}
|
||||
if (fragments != NULL) {
|
||||
delete[] fragments;
|
||||
}
|
||||
delete[] fragments;
|
||||
// TODO(daria): maybe a threshold of badness for
|
||||
// worst_near_fragment would be useful.
|
||||
return worst_index_near_fragment != -1 ?
|
||||
|
@ -988,7 +988,7 @@ float LanguageModel::ComputeNgramCost(const char *unichar,
|
||||
unichar, context_ptr, CertaintyScore(certainty)/denom, prob,
|
||||
ngram_and_classifier_cost);
|
||||
}
|
||||
if (modified_context != NULL) delete[] modified_context;
|
||||
delete[] modified_context;
|
||||
return ngram_and_classifier_cost;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user