From f99be62c4ca4f0a4dc07c52a6e305d064048f977 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Mon, 25 Jun 2018 14:27:35 +0200 Subject: [PATCH] coutln: Replace alloc_mem, free_mem by standard functions Signed-off-by: Stefan Weil --- src/ccstruct/coutln.cpp | 14 +++++--------- src/ccstruct/coutln.h | 9 +++------ 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/src/ccstruct/coutln.cpp b/src/ccstruct/coutln.cpp index 0de696fa..fb4ccbbc 100644 --- a/src/ccstruct/coutln.cpp +++ b/src/ccstruct/coutln.cpp @@ -64,8 +64,7 @@ C_OUTLINE::C_OUTLINE(CRACKEDGE* startpt, ICOORD bot_left, ICOORD top_right, return; } //get memory - steps = (uint8_t *) alloc_mem (step_mem()); - memset(steps, 0, step_mem()); + steps = (uint8_t *)calloc(step_mem(), 1); edgept = startpt; for (stepindex = 0; stepindex < length; stepindex++) { @@ -98,8 +97,7 @@ int16_t length //length of loop pos = startpt; stepcount = length; // No. of steps. ASSERT_HOST(length >= 0); - steps = static_cast(alloc_mem(step_mem())); // Get memory. - memset(steps, 0, step_mem()); + steps = static_cast(calloc(step_mem(), 1)); // Get memory. lastdir = new_steps[length - 1]; prevdir = lastdir; @@ -162,8 +160,7 @@ C_OUTLINE::C_OUTLINE(C_OUTLINE* srcline, FCOORD rotation) : offsets(nullptr) { return; } //get memory - steps = (uint8_t *) alloc_mem (step_mem()); - memset(steps, 0, step_mem()); + steps = (uint8_t *)calloc(step_mem(), 1); for (int iteration = 0; iteration < 2; ++iteration) { DIR128 round1 = iteration == 0 ? 32 : 0; @@ -1014,10 +1011,9 @@ void C_OUTLINE::plot_normed(const DENORM& denorm, ScrollView::Color colour, C_OUTLINE& C_OUTLINE::operator=(const C_OUTLINE& source) { box = source.box; start = source.start; - if (steps != nullptr) - free_mem(steps); + free(steps); stepcount = source.stepcount; - steps = (uint8_t *) alloc_mem (step_mem()); + steps = (uint8_t *)malloc(step_mem()); memmove (steps, source.steps, step_mem()); if (!children.empty ()) children.clear (); diff --git a/src/ccstruct/coutln.h b/src/ccstruct/coutln.h index 88a08918..165e53e0 100644 --- a/src/ccstruct/coutln.h +++ b/src/ccstruct/coutln.h @@ -24,7 +24,6 @@ #include "bits16.h" // for BITS16 #include "elst.h" // for ELIST_ITERATOR, ELISTIZEH, ELIST_LINK #include "ipoints.h" // for operator+= -#include "memry.h" // for free_mem #include "mod128.h" // for DIR128, DIRBITS #include "platform.h" // for DLLSYM #include "points.h" // for ICOORD, FCOORD @@ -92,9 +91,7 @@ class DLLSYM C_OUTLINE:public ELIST_LINK { static void FakeOutline(const TBOX& box, C_OUTLINE_LIST* outlines); ~C_OUTLINE () { //destructor - if (steps != nullptr) - free_mem(steps); - steps = nullptr; + free(steps); delete [] offsets; } @@ -286,9 +283,9 @@ class DLLSYM C_OUTLINE:public ELIST_LINK { TBOX box; // bounding box ICOORD start; // start coord - int16_t stepcount; // no of steps + int16_t stepcount; // no of steps BITS16 flags; // flags about outline - uint8_t *steps; // step array + uint8_t *steps; // step array EdgeOffset* offsets; // Higher precision edge. C_OUTLINE_LIST children; // child elements static ICOORD step_coords[4];