Skip to content

Commit 78d9170

Browse files
committed
Simplify new operations
It is not necessary to check for null pointers after new. Signed-off-by: Stefan Weil <[email protected]>
1 parent 03eec61 commit 78d9170

File tree

5 files changed

+0
-16
lines changed

5 files changed

+0
-16
lines changed

api/pdfrenderer.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -819,10 +819,6 @@ bool TessPDFRenderer::imageToPDFObj(Pix *pix,
819819
*pdf_object_size =
820820
b1_len + colorspace_len + b2_len + cid->nbytescomp + b3_len;
821821
*pdf_object = new char[*pdf_object_size];
822-
if (!pdf_object) {
823-
l_CIDataDestroy(&cid);
824-
return false;
825-
}
826822

827823
char *p = *pdf_object;
828824
memcpy(p, b1, b1_len);

dict/trie.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,6 @@ bool Trie::add_word_to_dawg(const WERD_CHOICE &word,
276276

277277
NODE_REF Trie::new_dawg_node() {
278278
TRIE_NODE_RECORD *node = new TRIE_NODE_RECORD();
279-
if (node == NULL) return 0; // failed to create new node
280279
nodes_.push_back(node);
281280
return nodes_.length() - 1;
282281
}

neural_networks/runtime/neural_net.cpp

-6
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,6 @@ bool NeuralNet::CreateFastNet() {
157157
node->fan_in_cnt = neurons_[node_idx].fan_in_cnt();
158158
// allocate memory for fan-in nodes
159159
node->inputs = new WeightedNode[node->fan_in_cnt];
160-
if (node->inputs == NULL) {
161-
return false;
162-
}
163160
for (int fan_in = 0; fan_in < node->fan_in_cnt; fan_in++) {
164161
// identify fan-in neuron
165162
const int id = neurons_[node_idx].fan_in(fan_in)->id();
@@ -222,9 +219,6 @@ NeuralNet *NeuralNet::FromFile(const string file_name) {
222219
NeuralNet *NeuralNet::FromInputBuffer(InputFileBuffer *ib) {
223220
// create a new net object
224221
NeuralNet *net_obj = new NeuralNet();
225-
if (net_obj == NULL) {
226-
return NULL;
227-
}
228222
// load the net
229223
if (!net_obj->ReadBinary(ib)) {
230224
delete net_obj;

neural_networks/runtime/neural_net.h

-3
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,6 @@ class NeuralNet {
140140
}
141141
// set the size of the neurons vector
142142
neurons_ = new Neuron[neuron_cnt_];
143-
if (neurons_ == NULL) {
144-
return false;
145-
}
146143
// read & validate inputs
147144
if (input_buff->Read(&read_val, sizeof(read_val)) != sizeof(read_val)) {
148145
return false;

textord/topitch.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -1285,8 +1285,6 @@ float tune_row_pitch2( //find fp cells
12851285
return initial_pitch;
12861286
}
12871287
sum_proj = new STATS[textord_pitch_range * 2 + 1];
1288-
if (sum_proj == NULL)
1289-
return initial_pitch;
12901288

12911289
for (pitch_delta = -textord_pitch_range; pitch_delta <= textord_pitch_range;
12921290
pitch_delta++)

0 commit comments

Comments
 (0)