Skip to content

Commit d80af6c

Browse files
committed
Fixed some memory leaks
Signed-off-by: Maciej Kurc <[email protected]>
1 parent 18bada5 commit d80af6c

File tree

1 file changed

+16
-20
lines changed

1 file changed

+16
-20
lines changed

libs/libarchfpga/src/read_fpga_interchange_arch.cpp

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,7 +1078,7 @@ struct ArchReader {
10781078
omode->num_pb_type_children = 1;
10791079
omode->pb_type_children = new t_pb_type[1];
10801080

1081-
auto opad = new t_pb_type;
1081+
auto opad = &omode->pb_type_children[0];
10821082
opad->name = vtr::strdup("opad");
10831083
opad->num_pb = 1;
10841084
opad->parent_mode = omode;
@@ -1090,7 +1090,6 @@ struct ArchReader {
10901090
opad->model = get_model(arch_, std::string(MODEL_OUTPUT));
10911091

10921092
opad->ports[0] = get_generic_port(arch_, opad, IN_PORT, "outpad", MODEL_OUTPUT);
1093-
omode->pb_type_children[0] = *opad;
10941093

10951094
// IPAD mode
10961095
auto imode = &pad->modes[1];
@@ -1100,7 +1099,7 @@ struct ArchReader {
11001099
imode->num_pb_type_children = 1;
11011100
imode->pb_type_children = new t_pb_type[1];
11021101

1103-
auto ipad = new t_pb_type;
1102+
auto ipad = &imode->pb_type_children[0];
11041103
ipad->name = vtr::strdup("ipad");
11051104
ipad->num_pb = 1;
11061105
ipad->parent_mode = imode;
@@ -1112,7 +1111,6 @@ struct ArchReader {
11121111
ipad->model = get_model(arch_, std::string(MODEL_INPUT));
11131112

11141113
ipad->ports[0] = get_generic_port(arch_, ipad, OUT_PORT, "inpad", MODEL_INPUT);
1115-
imode->pb_type_children[0] = *ipad;
11161114

11171115
// Handle interconnects
11181116
int num_pins = 1;
@@ -1131,8 +1129,8 @@ struct ArchReader {
11311129
std::string ipad_ostr = std::string(pad->name) + std::string(".") + opin;
11321130
std::string i_ic_name = std::string(ipad->name) + std::string("_") + std::string(pad->name);
11331131

1134-
auto o_ic = new t_interconnect[num_pins];
1135-
auto i_ic = new t_interconnect[num_pins];
1132+
auto o_ic = &omode->interconnect[0];
1133+
auto i_ic = &imode->interconnect[0];
11361134

11371135
o_ic->name = vtr::strdup(o_ic_name.c_str());
11381136
o_ic->type = DIRECT_INTERC;
@@ -1148,8 +1146,6 @@ struct ArchReader {
11481146
i_ic->input_string = vtr::strdup(ipad_istr.c_str());
11491147
i_ic->output_string = vtr::strdup(ipad_ostr.c_str());
11501148

1151-
omode->interconnect[0] = *o_ic;
1152-
imode->interconnect[0] = *i_ic;
11531149
}
11541150

11551151
void process_generic_block(t_pb_type* pb_type, Device::BEL::Reader& bel) {
@@ -1362,23 +1358,23 @@ struct ArchReader {
13621358
}
13631359

13641360
t_pin_to_pin_annotation get_pack_pattern(std::string ic_name, std::string input, std::string output) {
1365-
auto pp = new t_pin_to_pin_annotation;
1361+
t_pin_to_pin_annotation pp;
13661362

13671363
std::string pp_name = ic_name + "_" + output;
13681364

1369-
pp->prop = (int*)vtr::calloc(1, sizeof(int));
1370-
pp->value = (char**)vtr::calloc(1, sizeof(char*));
1365+
pp.prop = (int*)vtr::calloc(1, sizeof(int));
1366+
pp.value = (char**)vtr::calloc(1, sizeof(char*));
13711367

1372-
pp->type = E_ANNOT_PIN_TO_PIN_PACK_PATTERN;
1373-
pp->format = E_ANNOT_PIN_TO_PIN_CONSTANT;
1374-
pp->prop[0] = (int)E_ANNOT_PIN_TO_PIN_PACK_PATTERN_NAME;
1375-
pp->value[0] = vtr::strdup(pp_name.c_str());
1376-
pp->input_pins = vtr::strdup(input.c_str());
1377-
pp->output_pins = vtr::strdup(output.c_str());
1378-
pp->num_value_prop_pairs = 1;
1379-
pp->clock = nullptr;
1368+
pp.type = E_ANNOT_PIN_TO_PIN_PACK_PATTERN;
1369+
pp.format = E_ANNOT_PIN_TO_PIN_CONSTANT;
1370+
pp.prop[0] = (int)E_ANNOT_PIN_TO_PIN_PACK_PATTERN_NAME;
1371+
pp.value[0] = vtr::strdup(pp_name.c_str());
1372+
pp.input_pins = vtr::strdup(input.c_str());
1373+
pp.output_pins = vtr::strdup(output.c_str());
1374+
pp.num_value_prop_pairs = 1;
1375+
pp.clock = nullptr;
13801376

1381-
return *pp;
1377+
return pp;
13821378
}
13831379

13841380
// Physical Tiles

0 commit comments

Comments
 (0)