mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2025-01-21 08:43:03 +08:00
Replace malloc / free by new / delete for MFEDGEPT
Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
parent
0c3d244238
commit
174210c849
@ -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
|
||||
|
@ -99,8 +99,6 @@ void FreeOutlines(LIST Outlines);
|
||||
|
||||
void MarkDirectionChanges(MFOUTLINE Outline);
|
||||
|
||||
MFEDGEPT *NewEdgePoint();
|
||||
|
||||
MFOUTLINE NextExtremity(MFOUTLINE EdgePoint);
|
||||
|
||||
void NormalizeOutline(MFOUTLINE Outline, float XOrigin);
|
||||
|
Loading…
Reference in New Issue
Block a user