Skip to content

Commit

Permalink
Replace malloc / free by new / delete for MFEDGEPT
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Weil <[email protected]>
  • Loading branch information
stweil committed Mar 28, 2021
1 parent 0c3d244 commit 174210c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 17 deletions.
20 changes: 5 additions & 15 deletions src/classify/mfoutline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -187,12 +183,6 @@ void MarkDirectionChanges(MFOUTLINE Outline) {

} /* MarkDirectionChanges */

/*---------------------------------------------------------------------------*/
/** Return a new edge point for a micro-feature outline. */
MFEDGEPT *NewEdgePoint() {
return reinterpret_cast<MFEDGEPT *>(malloc(sizeof(MFEDGEPT)));
}

/*---------------------------------------------------------------------------*/
/**
* This routine returns the next point in the micro-feature
Expand Down
2 changes: 0 additions & 2 deletions src/classify/mfoutline.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ void FreeOutlines(LIST Outlines);

void MarkDirectionChanges(MFOUTLINE Outline);

MFEDGEPT *NewEdgePoint();

MFOUTLINE NextExtremity(MFOUTLINE EdgePoint);

void NormalizeOutline(MFOUTLINE Outline, float XOrigin);
Expand Down

0 comments on commit 174210c

Please sign in to comment.