Skip to content

Commit

Permalink
Replace malloc / free by new / delete for MICROFEATURE
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Weil <sw@weilnetz.de>
  • Loading branch information
stweil committed Mar 28, 2021
1 parent 30f44f3 commit 486c257
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/classify/mfdefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace tesseract {
* @return New MICROFEATURE
*/
MICROFEATURE NewMicroFeature() {
return (static_cast<MICROFEATURE>(malloc(sizeof(MFBLOCK))));
return new MFBLOCK;
} /* NewMicroFeature */

/**
Expand All @@ -40,7 +40,11 @@ MICROFEATURE NewMicroFeature() {
* @param MicroFeatures list of micro-features to be freed
*/
void FreeMicroFeatures(MICROFEATURES MicroFeatures) {
destroy_nodes(MicroFeatures, free);
auto list = MicroFeatures;
while (list != NIL_LIST) {
delete first_node(list);
list = pop(list);
}
} /* FreeMicroFeatures */

} // namespace tesseract

0 comments on commit 486c257

Please sign in to comment.