Skip to content

Commit f99be62

Browse files
committed
coutln: Replace alloc_mem, free_mem by standard functions
Signed-off-by: Stefan Weil <[email protected]>
1 parent b6eb22c commit f99be62

File tree

2 files changed

+8
-15
lines changed

2 files changed

+8
-15
lines changed

src/ccstruct/coutln.cpp

+5-9
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,7 @@ C_OUTLINE::C_OUTLINE(CRACKEDGE* startpt, ICOORD bot_left, ICOORD top_right,
6464
return;
6565
}
6666
//get memory
67-
steps = (uint8_t *) alloc_mem (step_mem());
68-
memset(steps, 0, step_mem());
67+
steps = (uint8_t *)calloc(step_mem(), 1);
6968
edgept = startpt;
7069

7170
for (stepindex = 0; stepindex < length; stepindex++) {
@@ -98,8 +97,7 @@ int16_t length //length of loop
9897
pos = startpt;
9998
stepcount = length; // No. of steps.
10099
ASSERT_HOST(length >= 0);
101-
steps = static_cast<uint8_t*>(alloc_mem(step_mem())); // Get memory.
102-
memset(steps, 0, step_mem());
100+
steps = static_cast<uint8_t*>(calloc(step_mem(), 1)); // Get memory.
103101

104102
lastdir = new_steps[length - 1];
105103
prevdir = lastdir;
@@ -162,8 +160,7 @@ C_OUTLINE::C_OUTLINE(C_OUTLINE* srcline, FCOORD rotation) : offsets(nullptr) {
162160
return;
163161
}
164162
//get memory
165-
steps = (uint8_t *) alloc_mem (step_mem());
166-
memset(steps, 0, step_mem());
163+
steps = (uint8_t *)calloc(step_mem(), 1);
167164

168165
for (int iteration = 0; iteration < 2; ++iteration) {
169166
DIR128 round1 = iteration == 0 ? 32 : 0;
@@ -1014,10 +1011,9 @@ void C_OUTLINE::plot_normed(const DENORM& denorm, ScrollView::Color colour,
10141011
C_OUTLINE& C_OUTLINE::operator=(const C_OUTLINE& source) {
10151012
box = source.box;
10161013
start = source.start;
1017-
if (steps != nullptr)
1018-
free_mem(steps);
1014+
free(steps);
10191015
stepcount = source.stepcount;
1020-
steps = (uint8_t *) alloc_mem (step_mem());
1016+
steps = (uint8_t *)malloc(step_mem());
10211017
memmove (steps, source.steps, step_mem());
10221018
if (!children.empty ())
10231019
children.clear ();

src/ccstruct/coutln.h

+3-6
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#include "bits16.h" // for BITS16
2525
#include "elst.h" // for ELIST_ITERATOR, ELISTIZEH, ELIST_LINK
2626
#include "ipoints.h" // for operator+=
27-
#include "memry.h" // for free_mem
2827
#include "mod128.h" // for DIR128, DIRBITS
2928
#include "platform.h" // for DLLSYM
3029
#include "points.h" // for ICOORD, FCOORD
@@ -92,9 +91,7 @@ class DLLSYM C_OUTLINE:public ELIST_LINK {
9291
static void FakeOutline(const TBOX& box, C_OUTLINE_LIST* outlines);
9392

9493
~C_OUTLINE () { //destructor
95-
if (steps != nullptr)
96-
free_mem(steps);
97-
steps = nullptr;
94+
free(steps);
9895
delete [] offsets;
9996
}
10097

@@ -286,9 +283,9 @@ class DLLSYM C_OUTLINE:public ELIST_LINK {
286283

287284
TBOX box; // bounding box
288285
ICOORD start; // start coord
289-
int16_t stepcount; // no of steps
286+
int16_t stepcount; // no of steps
290287
BITS16 flags; // flags about outline
291-
uint8_t *steps; // step array
288+
uint8_t *steps; // step array
292289
EdgeOffset* offsets; // Higher precision edge.
293290
C_OUTLINE_LIST children; // child elements
294291
static ICOORD step_coords[4];

0 commit comments

Comments
 (0)