From 174210c849957de856ec0b3d9b99f4aa387380ae Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Sun, 28 Mar 2021 22:24:51 +0200 Subject: [PATCH] Replace malloc / free by new / delete for MFEDGEPT Signed-off-by: Stefan Weil --- src/classify/mfoutline.cpp | 20 +++++--------------- src/classify/mfoutline.h | 2 -- 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/src/classify/mfoutline.cpp b/src/classify/mfoutline.cpp index e56735550..760c518d7 100644 --- a/src/classify/mfoutline.cpp +++ b/src/classify/mfoutline.cpp @@ -39,24 +39,20 @@ LIST ConvertBlob(TBLOB *blob) { /*---------------------------------------------------------------------------*/ /** Convert a TESSLINE into the float-based MFOUTLINE micro-feature format. */ MFOUTLINE ConvertOutline(TESSLINE *outline) { - MFEDGEPT *NewPoint; auto MFOutline = NIL_LIST; - EDGEPT *EdgePoint; - EDGEPT *StartPoint; - EDGEPT *NextPoint; if (outline == nullptr || outline->loop == nullptr) { return MFOutline; } - StartPoint = outline->loop; - EdgePoint = StartPoint; + auto StartPoint = outline->loop; + auto EdgePoint = StartPoint; do { - NextPoint = EdgePoint->next; + auto NextPoint = EdgePoint->next; /* filter out duplicate points */ if (EdgePoint->pos.x != NextPoint->pos.x || EdgePoint->pos.y != NextPoint->pos.y) { - NewPoint = NewEdgePoint(); + auto NewPoint = new MFEDGEPT; NewPoint->ClearMark(); NewPoint->Hidden = EdgePoint->IsHidden(); NewPoint->Point.x = EdgePoint->pos.x; @@ -141,7 +137,7 @@ void FreeMFOutline(void *arg) { // MFOUTLINE Outline) Start = list_rest(Outline); set_rest(Outline, NIL_LIST); while (Start != nullptr) { - free(first_node(Start)); + delete first_node(Start); Start = pop(Start); } @@ -187,12 +183,6 @@ void MarkDirectionChanges(MFOUTLINE Outline) { } /* MarkDirectionChanges */ -/*---------------------------------------------------------------------------*/ -/** Return a new edge point for a micro-feature outline. */ -MFEDGEPT *NewEdgePoint() { - return reinterpret_cast(malloc(sizeof(MFEDGEPT))); -} - /*---------------------------------------------------------------------------*/ /** * This routine returns the next point in the micro-feature diff --git a/src/classify/mfoutline.h b/src/classify/mfoutline.h index 4f71dda2b..f2707a254 100644 --- a/src/classify/mfoutline.h +++ b/src/classify/mfoutline.h @@ -99,8 +99,6 @@ void FreeOutlines(LIST Outlines); void MarkDirectionChanges(MFOUTLINE Outline); -MFEDGEPT *NewEdgePoint(); - MFOUTLINE NextExtremity(MFOUTLINE EdgePoint); void NormalizeOutline(MFOUTLINE Outline, float XOrigin);