@@ -1303,17 +1303,13 @@ void EdgeDrawingImpl::JoinAnchorPointsUsingSortedAnchors()
1303
1303
delete[] pixels;
1304
1304
}
1305
1305
1306
- int * EdgeDrawingImpl::sortAnchorsByGradValue1 ()
1307
- {
1308
- int SIZE = 128 * 256 ;
1309
- int * C = new int [SIZE];
1310
- memset (C, 0 , sizeof (int ) * SIZE);
1306
+ int * EdgeDrawingImpl::sortAnchorsByGradValue1 () {
1307
+ const int SIZE = 128 * 256 ;
1308
+ std::vector<int > C (SIZE, 0 );
1311
1309
1312
1310
// Count the number of grad values
1313
- for (int i = 1 ; i < height - 1 ; i++)
1314
- {
1315
- for (int j = 1 ; j < width - 1 ; j++)
1316
- {
1311
+ for (int i = 1 ; i < height - 1 ; i++) {
1312
+ for (int j = 1 ; j < width - 1 ; j++) {
1317
1313
if (edgeImg[i * width + j] != ANCHOR_PIXEL)
1318
1314
continue ;
1319
1315
@@ -1323,16 +1319,15 @@ int* EdgeDrawingImpl::sortAnchorsByGradValue1()
1323
1319
}
1324
1320
1325
1321
// Compute indices
1326
- for (int i = 1 ; i < SIZE; i++)
1322
+ for (int i = 1 ; i < SIZE; i++) {
1327
1323
C[i] += C[i - 1 ];
1324
+ }
1328
1325
1329
1326
int noAnchors = C[SIZE - 1 ];
1330
1327
int * A = new int [noAnchors];
1331
1328
1332
- for (int i = 1 ; i < height - 1 ; i++)
1333
- {
1334
- for (int j = 1 ; j < width - 1 ; j++)
1335
- {
1329
+ for (int i = 1 ; i < height - 1 ; i++) {
1330
+ for (int j = 1 ; j < width - 1 ; j++) {
1336
1331
if (edgeImg[i * width + j] != ANCHOR_PIXEL)
1337
1332
continue ;
1338
1333
@@ -1342,7 +1337,6 @@ int* EdgeDrawingImpl::sortAnchorsByGradValue1()
1342
1337
}
1343
1338
}
1344
1339
1345
- delete[] C;
1346
1340
return A;
1347
1341
}
1348
1342
0 commit comments