Skip to content

Commit 2c12600

Browse files
committed
undid a couple changes to fix odin memory leak
1 parent 7cb2095 commit 2c12600

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

libs/libarchfpga/src/arch_util.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ static void free_pb_type(t_pb_type* pb_type) {
367367
}
368368
}
369369
if (pb_type->num_annotations > 0) {
370-
delete[] pb_type->annotations;
370+
vtr::free(pb_type->annotations);
371371
}
372372

373373
if (pb_type->pb_type_power) {
@@ -525,7 +525,7 @@ void alloc_and_load_default_child_for_pb_type(t_pb_type* pb_type,
525525
}
526526
}
527527

528-
copy->annotations = new t_pin_to_pin_annotation[pb_type->num_annotations]();
528+
copy->annotations = (t_pin_to_pin_annotation*)vtr::calloc(pb_type->num_annotations, sizeof(t_pin_to_pin_annotation));
529529
copy->num_annotations = pb_type->num_annotations;
530530
for (i = 0; i < copy->num_annotations; i++) {
531531
copy->annotations[i].clock = vtr::strdup(pb_type->annotations[i].clock);
@@ -659,7 +659,7 @@ void ProcessLutClass(t_pb_type* lut_pb_type) {
659659
}
660660
}
661661
lut_pb_type->num_annotations = 0;
662-
delete[] lut_pb_type->annotations;
662+
vtr::free(lut_pb_type->annotations);
663663
lut_pb_type->annotations = nullptr;
664664
lut_pb_type->modes[1].pb_type_children[0].depth = lut_pb_type->depth + 1;
665665
lut_pb_type->modes[1].pb_type_children[0].parent_mode = &lut_pb_type->modes[1];

libs/libarchfpga/src/read_xml_arch_file.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1375,7 +1375,7 @@ static void ProcessPb_Type(pugi::xml_node Parent,
13751375
num_annotations += count_children(Parent, child_name, loc_data, ReqOpt::OPTIONAL);
13761376
}
13771377

1378-
pb_type->annotations = new t_pin_to_pin_annotation[num_annotations]();
1378+
pb_type->annotations = (t_pin_to_pin_annotation*)vtr::calloc(num_annotations, sizeof(t_pin_to_pin_annotation));
13791379
pb_type->num_annotations = num_annotations;
13801380

13811381
int annotation_idx = 0;

0 commit comments

Comments
 (0)