mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2025-01-18 06:30:14 +08:00
Merge pull request #857 from stweil/new_delete
Avoid unnecessary new / delete code
This commit is contained in:
commit
6e80812ac8
@ -2051,18 +2051,12 @@ void TessBaseAPI::Clear() {
|
||||
*/
|
||||
void TessBaseAPI::End() {
|
||||
Clear();
|
||||
if (thresholder_ != NULL) {
|
||||
delete thresholder_;
|
||||
thresholder_ = NULL;
|
||||
}
|
||||
if (page_res_ != NULL) {
|
||||
delete page_res_;
|
||||
page_res_ = NULL;
|
||||
}
|
||||
if (block_list_ != NULL) {
|
||||
delete block_list_;
|
||||
block_list_ = NULL;
|
||||
}
|
||||
delete thresholder_;
|
||||
thresholder_ = NULL;
|
||||
delete page_res_;
|
||||
page_res_ = NULL;
|
||||
delete block_list_;
|
||||
block_list_ = NULL;
|
||||
if (paragraph_models_ != NULL) {
|
||||
paragraph_models_->delete_data_pointers();
|
||||
delete paragraph_models_;
|
||||
@ -2074,30 +2068,18 @@ void TessBaseAPI::End() {
|
||||
osd_tesseract_ = NULL;
|
||||
tesseract_ = NULL;
|
||||
}
|
||||
if (osd_tesseract_ != NULL) {
|
||||
delete osd_tesseract_;
|
||||
osd_tesseract_ = NULL;
|
||||
}
|
||||
if (equ_detect_ != NULL) {
|
||||
delete equ_detect_;
|
||||
equ_detect_ = NULL;
|
||||
}
|
||||
if (input_file_ != NULL) {
|
||||
delete input_file_;
|
||||
input_file_ = NULL;
|
||||
}
|
||||
if (output_file_ != NULL) {
|
||||
delete output_file_;
|
||||
output_file_ = NULL;
|
||||
}
|
||||
if (datapath_ != NULL) {
|
||||
delete datapath_;
|
||||
datapath_ = NULL;
|
||||
}
|
||||
if (language_ != NULL) {
|
||||
delete language_;
|
||||
language_ = NULL;
|
||||
}
|
||||
delete osd_tesseract_;
|
||||
osd_tesseract_ = NULL;
|
||||
delete equ_detect_;
|
||||
equ_detect_ = NULL;
|
||||
delete input_file_;
|
||||
input_file_ = NULL;
|
||||
delete output_file_;
|
||||
output_file_ = NULL;
|
||||
delete datapath_;
|
||||
datapath_ = NULL;
|
||||
delete language_;
|
||||
language_ = NULL;
|
||||
}
|
||||
|
||||
// Clear any library-level memory caches.
|
||||
|
@ -90,10 +90,7 @@ void STATS::clear() { // clear out buckets
|
||||
* Destructor for a stats class.
|
||||
**********************************************************************/
|
||||
STATS::~STATS () {
|
||||
if (buckets_ != NULL) {
|
||||
delete [] buckets_;
|
||||
buckets_ = NULL;
|
||||
}
|
||||
delete [] buckets_;
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
|
@ -184,9 +184,6 @@ Classify::Classify()
|
||||
learn_debug_win_ = NULL;
|
||||
learn_fragmented_word_debug_win_ = NULL;
|
||||
learn_fragments_debug_win_ = NULL;
|
||||
|
||||
CharNormCutoffs = new uinT16[MAX_NUM_CLASSES];
|
||||
BaselineCutoffs = new uinT16[MAX_NUM_CLASSES];
|
||||
}
|
||||
|
||||
Classify::~Classify() {
|
||||
@ -194,8 +191,6 @@ Classify::~Classify() {
|
||||
delete learn_debug_win_;
|
||||
delete learn_fragmented_word_debug_win_;
|
||||
delete learn_fragments_debug_win_;
|
||||
delete[] CharNormCutoffs;
|
||||
delete[] BaselineCutoffs;
|
||||
}
|
||||
|
||||
|
||||
|
@ -529,8 +529,8 @@ class Classify : public CCStruct {
|
||||
// value in the adaptive classifier. Both are indexed by unichar_id.
|
||||
// shapetable_cutoffs_ provides a similar value for each shape in the
|
||||
// shape_table_
|
||||
uinT16* CharNormCutoffs;
|
||||
uinT16* BaselineCutoffs;
|
||||
uinT16 CharNormCutoffs[MAX_NUM_CLASSES];
|
||||
uinT16 BaselineCutoffs[MAX_NUM_CLASSES];
|
||||
GenericVector<uinT16> shapetable_cutoffs_;
|
||||
ScrollView* learn_debug_win_;
|
||||
ScrollView* learn_fragmented_word_debug_win_;
|
||||
|
@ -208,19 +208,19 @@ void SVSemaphore::Wait() {
|
||||
|
||||
// Place a message in the message buffer (and flush it).
|
||||
void SVNetwork::Send(const char* msg) {
|
||||
mutex_send_->Lock();
|
||||
mutex_send_.Lock();
|
||||
msg_buffer_out_.append(msg);
|
||||
mutex_send_->Unlock();
|
||||
mutex_send_.Unlock();
|
||||
}
|
||||
|
||||
// Send the whole buffer.
|
||||
void SVNetwork::Flush() {
|
||||
mutex_send_->Lock();
|
||||
mutex_send_.Lock();
|
||||
while (!msg_buffer_out_.empty()) {
|
||||
int i = send(stream_, msg_buffer_out_.c_str(), msg_buffer_out_.length(), 0);
|
||||
msg_buffer_out_.erase(0, i);
|
||||
}
|
||||
mutex_send_->Unlock();
|
||||
mutex_send_.Unlock();
|
||||
}
|
||||
|
||||
// Receive a message from the server.
|
||||
@ -387,7 +387,6 @@ static int GetAddrInfo(const char* hostname, int port,
|
||||
|
||||
// Set up a connection to a ScrollView on hostname:port.
|
||||
SVNetwork::SVNetwork(const char* hostname, int port) {
|
||||
mutex_send_ = new SVMutex();
|
||||
msg_buffer_in_ = new char[kMaxMsgSize + 1];
|
||||
msg_buffer_in_[0] = '\0';
|
||||
|
||||
@ -448,7 +447,6 @@ SVNetwork::SVNetwork(const char* hostname, int port) {
|
||||
|
||||
SVNetwork::~SVNetwork() {
|
||||
delete[] msg_buffer_in_;
|
||||
delete mutex_send_;
|
||||
}
|
||||
|
||||
#endif // GRAPHICS_DISABLED
|
||||
|
@ -141,7 +141,7 @@ class SVNetwork {
|
||||
|
||||
private:
|
||||
/// The mutex for access to Send() and Flush().
|
||||
SVMutex* mutex_send_;
|
||||
SVMutex mutex_send_;
|
||||
/// The actual stream_ to the server.
|
||||
int stream_;
|
||||
/// Stores the last received message-chunk from the server.
|
||||
|
Loading…
Reference in New Issue
Block a user