Replace malloc / free by new / delete for MFEDGEPT

Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
Stefan Weil 2021-03-28 22:24:51 +02:00
parent 0c3d244238
commit 174210c849
2 changed files with 5 additions and 17 deletions

View File

@ -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<MFEDGEPT *>(malloc(sizeof(MFEDGEPT)));
}
/*---------------------------------------------------------------------------*/
/**
* This routine returns the next point in the micro-feature

View File

@ -99,8 +99,6 @@ void FreeOutlines(LIST Outlines);
void MarkDirectionChanges(MFOUTLINE Outline);
MFEDGEPT *NewEdgePoint();
MFOUTLINE NextExtremity(MFOUTLINE EdgePoint);
void NormalizeOutline(MFOUTLINE Outline, float XOrigin);