@@ -46,15 +46,15 @@ void block_edges(Pix *t_pix, // thresholded image
46
46
int height = pixGetHeight (t_pix);
47
47
int wpl = pixGetWpl (t_pix);
48
48
// lines in progress
49
- CRACKEDGE **ptrline = new CRACKEDGE*[width + 1 ];
49
+ std::unique_ptr< CRACKEDGE*[]> ptrline ( new CRACKEDGE*[width + 1 ]) ;
50
50
CRACKEDGE *free_cracks = nullptr ;
51
51
52
52
block->bounding_box (bleft, tright); // block box
53
53
int block_width = tright.x () - bleft.x ();
54
54
for (int x = block_width; x >= 0 ; x--)
55
55
ptrline[x] = nullptr ; // no lines in progress
56
56
57
- uint8_t * bwline = new uint8_t [width];
57
+ std::unique_ptr< uint8_t []> bwline ( new uint8_t [width]) ;
58
58
59
59
uint8_t margin = WHITE_PIX;
60
60
@@ -65,17 +65,15 @@ void block_edges(Pix *t_pix, // thresholded image
65
65
for (int x = 0 ; x < block_width; ++x) {
66
66
bwline[x] = GET_DATA_BIT (line, x + bleft.x ()) ^ 1 ;
67
67
}
68
- make_margins (block, &line_it, bwline, margin, bleft.x (), tright.x (), y);
68
+ make_margins (block, &line_it, bwline. get () , margin, bleft.x (), tright.x (), y);
69
69
} else {
70
- memset (bwline, margin, block_width * sizeof (bwline[0 ]));
70
+ memset (bwline. get () , margin, block_width * sizeof (bwline[0 ]));
71
71
}
72
72
line_edges (bleft.x (), y, block_width,
73
- margin, bwline, ptrline, &free_cracks, outline_it);
73
+ margin, bwline. get () , ptrline. get () , &free_cracks, outline_it);
74
74
}
75
75
76
76
free_crackedges (free_cracks); // really free them
77
- delete[] ptrline;
78
- delete[] bwline;
79
77
}
80
78
81
79
@@ -94,14 +92,13 @@ void make_margins( //get a line
94
92
int16_t right,
95
93
int16_t y // line coord
96
94
) {
97
- PB_LINE_IT *lines;
98
95
ICOORDELT_IT seg_it;
99
96
int32_t start; // of segment
100
97
int16_t xext; // of segment
101
98
int xindex; // index to pixel
102
99
103
100
if (block->poly_block () != nullptr ) {
104
- lines = new PB_LINE_IT (block->poly_block ());
101
+ std::unique_ptr<PB_LINE_IT> lines ( new PB_LINE_IT (block->poly_block () ));
105
102
const std::unique_ptr</* non-const*/ ICOORDELT_LIST> segments (
106
103
lines->get_line (y));
107
104
if (!segments->empty ()) {
@@ -124,7 +121,6 @@ void make_margins( //get a line
124
121
for (xindex = left; xindex < right; xindex++)
125
122
pixels[xindex - left] = margin;
126
123
}
127
- delete lines;
128
124
}
129
125
else {
130
126
start = line_it->get_line (y, xext);
0 commit comments