Skip to content

Commit c985d61

Browse files
committed
Deallocate with delete[] if new[] has been used for allocation
Found by valgrind.
1 parent 1465a12 commit c985d61

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

ADOL-C/src/tape_handling.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -604,23 +604,23 @@ void cleanUp() {
604604
remove((*tiIter)->pTapeInfos.tay_fileName);
605605
}
606606
if ((*tiIter)->opBuffer != NULL) {
607-
free((*tiIter)->opBuffer);
607+
delete[] ((*tiIter)->opBuffer);
608608
(*tiIter)->opBuffer = NULL;
609609
}
610610
if ((*tiIter)->valBuffer != NULL) {
611-
free((*tiIter)->valBuffer);
611+
delete[] ((*tiIter)->valBuffer);
612612
(*tiIter)->valBuffer = NULL;
613613
}
614614
if ((*tiIter)->locBuffer != NULL) {
615-
free((*tiIter)->locBuffer);
615+
delete[] ((*tiIter)->locBuffer);
616616
(*tiIter)->locBuffer = NULL;
617617
}
618618
if ((*tiIter)->signature != NULL) {
619619
free((*tiIter)->signature);
620620
(*tiIter)->signature = NULL;
621621
}
622622
if ((*tiIter)->tayBuffer != NULL) {
623-
free((*tiIter)->tayBuffer);
623+
delete[] ((*tiIter)->tayBuffer);
624624
(*tiIter)->tayBuffer = NULL;
625625
}
626626

@@ -659,19 +659,19 @@ void cleanUp() {
659659
remove((*tiIter)->pTapeInfos.val_fileName);
660660
}
661661
if ((*tiIter)->pTapeInfos.op_fileName != NULL) {
662-
free((*tiIter)->pTapeInfos.op_fileName);
662+
delete[] ((*tiIter)->pTapeInfos.op_fileName);
663663
(*tiIter)->pTapeInfos.op_fileName = NULL;
664664
}
665665
if ((*tiIter)->pTapeInfos.val_fileName != NULL) {
666-
free((*tiIter)->pTapeInfos.val_fileName);
666+
delete[] ((*tiIter)->pTapeInfos.val_fileName);
667667
(*tiIter)->pTapeInfos.val_fileName = NULL;
668668
}
669669
if ((*tiIter)->pTapeInfos.loc_fileName != NULL) {
670-
free((*tiIter)->pTapeInfos.loc_fileName);
670+
delete[] ((*tiIter)->pTapeInfos.loc_fileName);
671671
(*tiIter)->pTapeInfos.loc_fileName = NULL;
672672
}
673673
if ((*tiIter)->pTapeInfos.tay_fileName != NULL) {
674-
free((*tiIter)->pTapeInfos.tay_fileName);
674+
delete[] ((*tiIter)->pTapeInfos.tay_fileName);
675675
(*tiIter)->pTapeInfos.tay_fileName = NULL;
676676
}
677677

@@ -1163,7 +1163,7 @@ PersistantTapeInfos::~PersistantTapeInfos() {
11631163
forodec_nax = 0;
11641164
}
11651165
if (paramstore != NULL) {
1166-
free(paramstore);
1166+
delete[] paramstore;
11671167
paramstore = NULL;
11681168
}
11691169
}

ADOL-C/src/taping.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ void clearTapeBaseNames() {
362362
int i;
363363
for (i = 0; i < 4; i++) {
364364
if (tapeBaseNames[i]) {
365-
delete tapeBaseNames[i];
365+
delete[] tapeBaseNames[i];
366366
tapeBaseNames[i] = nullptr;
367367
}
368368
}
@@ -1153,7 +1153,7 @@ static void save_params() {
11531153

11541154
ADOLC_CURRENT_TAPE_INFOS.stats[NUM_PARAM] = ADOLC_GLOBAL_TAPE_VARS.numparam;
11551155
if (ADOLC_CURRENT_TAPE_INFOS.pTapeInfos.paramstore != nullptr)
1156-
delete ADOLC_CURRENT_TAPE_INFOS.pTapeInfos.paramstore;
1156+
delete[] ADOLC_CURRENT_TAPE_INFOS.pTapeInfos.paramstore;
11571157

11581158
ADOLC_CURRENT_TAPE_INFOS.pTapeInfos.paramstore =
11591159
new double[ADOLC_CURRENT_TAPE_INFOS.stats[NUM_PARAM]];
@@ -1246,7 +1246,7 @@ void close_tape(int flag) {
12461246
fclose(ADOLC_CURRENT_TAPE_INFOS.op_file);
12471247
ADOLC_CURRENT_TAPE_INFOS.op_file = nullptr;
12481248
ADOLC_CURRENT_TAPE_INFOS.stats[OP_FILE_ACCESS] = 1;
1249-
delete ADOLC_CURRENT_TAPE_INFOS.opBuffer;
1249+
delete[] ADOLC_CURRENT_TAPE_INFOS.opBuffer;
12501250
ADOLC_CURRENT_TAPE_INFOS.opBuffer = nullptr;
12511251
} else {
12521252
ADOLC_CURRENT_TAPE_INFOS.numOps_Tape =
@@ -1290,7 +1290,7 @@ void close_tape(int flag) {
12901290
ADOLC_CURRENT_TAPE_INFOS.loc_file);
12911291
fclose(ADOLC_CURRENT_TAPE_INFOS.loc_file);
12921292
ADOLC_CURRENT_TAPE_INFOS.loc_file = nullptr;
1293-
delete ADOLC_CURRENT_TAPE_INFOS.locBuffer;
1293+
delete[] ADOLC_CURRENT_TAPE_INFOS.locBuffer;
12941294
ADOLC_CURRENT_TAPE_INFOS.locBuffer = nullptr;
12951295
} else {
12961296
ADOLC_CURRENT_TAPE_INFOS.numLocs_Tape =

0 commit comments

Comments
 (0)