From 957cad55b5cf41c9dd38a4891f604e1f893f3a7d Mon Sep 17 00:00:00 2001 From: Dustin DeWeese Date: Thu, 19 Dec 2019 17:16:48 -0800 Subject: [PATCH 1/3] replace some uses of malloc/free with std::unique_ptr Signed-off-by: Dustin DeWeese --- vpr/src/route/rr_graph.cpp | 16 ++-- vpr/src/route/rr_graph2.cpp | 160 +++++++++++++----------------------- vpr/src/route/rr_graph2.h | 6 +- 3 files changed, 68 insertions(+), 114 deletions(-) diff --git a/vpr/src/route/rr_graph.cpp b/vpr/src/route/rr_graph.cpp index df1bb8b0967..6c920b804c5 100644 --- a/vpr/src/route/rr_graph.cpp +++ b/vpr/src/route/rr_graph.cpp @@ -520,7 +520,7 @@ static void build_rr_graph(const t_graph_type graph_type, VTR_ASSERT(max_chan_width % 2 == 0); total_sets /= 2; } - int* sets_per_seg_type = get_seg_track_counts(total_sets, segment_inf, use_full_seg_groups); + auto sets_per_seg_type = get_seg_track_counts(total_sets, segment_inf, use_full_seg_groups); if (is_global_graph) { //All pins can connect during global routing @@ -529,13 +529,13 @@ static void build_rr_graph(const t_graph_type graph_type, Fc_out = std::vector>(types.size(), ones); } else { bool Fc_clipped = false; - Fc_in = alloc_and_load_actual_fc(types, max_pins, segment_inf, sets_per_seg_type, max_chan_width, + Fc_in = alloc_and_load_actual_fc(types, max_pins, segment_inf, sets_per_seg_type.get(), max_chan_width, e_fc_type::IN, directionality, &Fc_clipped); if (Fc_clipped) { *Warnings |= RR_GRAPH_WARN_FC_CLIPPED; } Fc_clipped = false; - Fc_out = alloc_and_load_actual_fc(types, max_pins, segment_inf, sets_per_seg_type, max_chan_width, + Fc_out = alloc_and_load_actual_fc(types, max_pins, segment_inf, sets_per_seg_type.get(), max_chan_width, e_fc_type::OUT, directionality, &Fc_clipped); if (Fc_clipped) { *Warnings |= RR_GRAPH_WARN_FC_CLIPPED; @@ -571,7 +571,7 @@ static void build_rr_graph(const t_graph_type graph_type, } auto perturb_ipins = alloc_and_load_perturb_ipins(types.size(), segment_inf.size(), - sets_per_seg_type, Fc_in, Fc_out, directionality); + sets_per_seg_type.get(), Fc_in, Fc_out, directionality); /* END FC */ /* Alloc node lookups, count nodes, alloc rr nodes */ @@ -655,7 +655,7 @@ static void build_rr_graph(const t_graph_type graph_type, for (unsigned int itype = 0; itype < types.size(); ++itype) { ipin_to_track_map[itype] = alloc_and_load_pin_to_track_map(RECEIVER, Fc_in[itype], &types[itype], perturb_ipins[itype], directionality, - segment_inf.size(), sets_per_seg_type); + segment_inf.size(), sets_per_seg_type.get()); track_to_pin_lookup[itype] = alloc_and_load_track_to_pin_lookup(ipin_to_track_map[itype], Fc_in[itype], types[itype].width, types[itype].height, types[itype].num_pins, max_chan_width, segment_inf.size()); @@ -672,7 +672,7 @@ static void build_rr_graph(const t_graph_type graph_type, max_chan_width, segment_inf); opin_to_track_map[itype] = alloc_and_load_pin_to_track_map(DRIVER, Fc_out[itype], &types[itype], perturb_opins, directionality, - segment_inf.size(), sets_per_seg_type); + segment_inf.size(), sets_per_seg_type.get()); } } /* END OPIN MAP */ @@ -734,10 +734,6 @@ static void build_rr_graph(const t_graph_type graph_type, free_switchblock_permutations(sb_conn_map); sb_conn_map = nullptr; } - if (sets_per_seg_type) { - free(sets_per_seg_type); - sets_per_seg_type = nullptr; - } free_type_track_to_pin_map(track_to_pin_lookup, types, max_chan_width); if (clb_to_clb_directs != nullptr) { diff --git a/vpr/src/route/rr_graph2.cpp b/vpr/src/route/rr_graph2.cpp index 556a879229f..58242c3b19d 100644 --- a/vpr/src/route/rr_graph2.cpp +++ b/vpr/src/route/rr_graph2.cpp @@ -88,26 +88,26 @@ static int vpr_to_phy_track(const int itrack, const t_chan_seg_details* seg_details, const enum e_directionality directionality); -static int* label_wire_muxes(const int chan_num, - const int seg_num, - const t_chan_seg_details* seg_details, - const int seg_type_index, - const int max_len, - const enum e_direction dir, - const int max_chan_width, - const bool check_cb, - int* num_wire_muxes, - int* num_wire_muxes_cb_restricted); - -static int* label_incoming_wires(const int chan_num, - const int seg_num, - const int sb_seg, - const t_chan_seg_details* seg_details, - const int max_len, - const enum e_direction dir, - const int max_chan_width, - int* num_incoming_wires, - int* num_ending_wires); +static std::unique_ptr label_wire_muxes(const int chan_num, + const int seg_num, + const t_chan_seg_details* seg_details, + const int seg_type_index, + const int max_len, + const enum e_direction dir, + const int max_chan_width, + const bool check_cb, + int* num_wire_muxes, + int* num_wire_muxes_cb_restricted); + +static std::unique_ptr label_incoming_wires(const int chan_num, + const int seg_num, + const int sb_seg, + const t_chan_seg_details* seg_details, + const int max_len, + const enum e_direction dir, + const int max_chan_width, + int* num_incoming_wires, + int* num_ending_wires); static int find_label_of_track(int* wire_mux_on_track, int num_wire_muxes, @@ -143,16 +143,14 @@ static bool should_apply_switch_override(int switch_override); * no longer less than the requested number of tracks. As a final * step, if we were closer to target before last more, undo it * and end up with a result that uses fewer tracks than given. */ -int* get_seg_track_counts(const int num_sets, - const std::vector& segment_inf, - const bool use_full_seg_groups) { - int* result; - double* demand; +std::unique_ptr get_seg_track_counts(const int num_sets, + const std::vector& segment_inf, + const bool use_full_seg_groups) { int imax, freq_sum, assigned, size; double scale, max, reduce; - result = (int*)vtr::malloc(sizeof(int) * segment_inf.size()); - demand = (double*)vtr::malloc(sizeof(double) * segment_inf.size()); + auto result = std::make_unique(segment_inf.size()); + auto demand = std::make_unique(segment_inf.size()); /* Scale factor so we can divide by any length * and still use integers */ @@ -199,13 +197,6 @@ int* get_seg_track_counts(const int num_sets, result[imax] -= size; } - /* Free temps */ - if (demand) { - vtr::free(demand); - demand = nullptr; - } - - /* This must be freed by caller */ return result; } @@ -228,7 +219,6 @@ t_seg_details* alloc_and_load_seg_details(int* max_chan_width, int cur_track, ntracks, itrack, length, j, index; int arch_wire_switch, arch_opin_switch, fac, num_sets, tmp; int group_start, first_track; - int* sets_per_seg_type = nullptr; t_seg_details* seg_details = nullptr; bool longline; @@ -245,8 +235,8 @@ t_seg_details* alloc_and_load_seg_details(int* max_chan_width, } /* Map segment type fractions and groupings to counts of tracks */ - sets_per_seg_type = get_seg_track_counts((*max_chan_width / fac), - segment_inf, use_full_seg_groups); + auto sets_per_seg_type = get_seg_track_counts((*max_chan_width / fac), + segment_inf, use_full_seg_groups); /* Count the number tracks actually assigned. */ tmp = 0; @@ -356,9 +346,6 @@ t_seg_details* alloc_and_load_seg_details(int* max_chan_width, } } /* End for each segment type. */ - /* free variables */ - vtr::free(sets_per_seg_type); - if (num_seg_details) { *num_seg_details = cur_track; } @@ -761,8 +748,6 @@ int get_unidir_opin_connections(const int chan, /* Gets a linked list of Fc nodes of specified seg_type_index to connect * to in given chan seg. Fc_ofs is used for the opin staggering pattern. */ - int* inc_muxes = nullptr; - int* dec_muxes = nullptr; int num_inc_muxes, num_dec_muxes, iconn; int inc_inode_index, dec_inode_index; int inc_mux, dec_mux; @@ -781,10 +766,10 @@ int get_unidir_opin_connections(const int chan, /* Get the lists of possible muxes. */ int dummy; - inc_muxes = label_wire_muxes(chan, seg, seg_details, seg_type_index, max_len, - INC_DIRECTION, max_chan_width, true, &num_inc_muxes, &dummy); - dec_muxes = label_wire_muxes(chan, seg, seg_details, seg_type_index, max_len, - DEC_DIRECTION, max_chan_width, true, &num_dec_muxes, &dummy); + auto inc_muxes = label_wire_muxes(chan, seg, seg_details, seg_type_index, max_len, + INC_DIRECTION, max_chan_width, true, &num_inc_muxes, &dummy); + auto dec_muxes = label_wire_muxes(chan, seg, seg_details, seg_type_index, max_len, + DEC_DIRECTION, max_chan_width, true, &num_dec_muxes, &dummy); /* Clip Fc to the number of muxes. */ if (((Fc / 2) > num_inc_muxes) || ((Fc / 2) > num_dec_muxes)) { @@ -823,15 +808,6 @@ int get_unidir_opin_connections(const int chan, ++num_edges; } - if (inc_muxes) { - vtr::free(inc_muxes); - inc_muxes = nullptr; - } - if (dec_muxes) { - vtr::free(dec_muxes); - dec_muxes = nullptr; - } - return num_edges; } @@ -1865,7 +1841,6 @@ static int get_unidir_track_to_chan_seg(const int from_track, const int from_rr_node, t_rr_edge_info_set& rr_edges_to_create) { int num_labels = 0; - int* mux_labels = nullptr; /* x, y coords for get_rr_node lookups */ int to_x = (CHANX == to_type ? to_seg : to_chan); @@ -1883,15 +1858,11 @@ static int get_unidir_track_to_chan_seg(const int from_track, /* get list of muxes to which we can connect */ int dummy; - mux_labels = label_wire_muxes(to_chan, to_seg, seg_details, UNDEFINED, max_len, - to_dir, max_chan_width, false, &num_labels, &dummy); + auto mux_labels = label_wire_muxes(to_chan, to_seg, seg_details, UNDEFINED, max_len, + to_dir, max_chan_width, false, &num_labels, &dummy); /* Can't connect if no muxes. */ if (num_labels < 1) { - if (mux_labels) { - vtr::free(mux_labels); - mux_labels = nullptr; - } return 0; } @@ -1944,10 +1915,6 @@ static int get_unidir_track_to_chan_seg(const int from_track, } } - if (mux_labels) { - vtr::free(mux_labels); - mux_labels = nullptr; - } return count; } @@ -2174,8 +2141,8 @@ void load_sblock_pattern_lookup(const int i, /* SB's range from (0, 0) to (grid.width() - 2, grid.height() - 2) */ /* First find all four sides' incoming wires */ - int* wire_mux_on_track[4]; - int* incoming_wire_label[4]; + std::unique_ptr wire_mux_on_track[4]; + std::unique_ptr incoming_wire_label[4]; int num_incoming_wires[4]; int num_ending_wires[4]; int num_wire_muxes[4]; @@ -2329,7 +2296,7 @@ void load_sblock_pattern_lookup(const int i, * use any pattern such as Wilton */ /* In the direct connect case, I know for sure the init mux is at the same track # * as this ending wire, but still need to find the init mux label for Fs > 3 */ - int mux = find_label_of_track(wire_mux_on_track[to_side], + int mux = find_label_of_track(wire_mux_on_track[to_side].get(), num_wire_muxes[to_side], itrack); sblock_pattern[i][j][side_opp][to_side][itrack][0] = mux; } else { @@ -2346,27 +2313,18 @@ void load_sblock_pattern_lookup(const int i, } } } - - for (e_side side : {TOP, RIGHT, BOTTOM, LEFT}) { - if (incoming_wire_label[side]) { - vtr::free(incoming_wire_label[side]); - } - if (wire_mux_on_track[side]) { - vtr::free(wire_mux_on_track[side]); - } - } } -static int* label_wire_muxes(const int chan_num, - const int seg_num, - const t_chan_seg_details* seg_details, - const int seg_type_index, - const int max_len, - const enum e_direction dir, - const int max_chan_width, - const bool check_cb, - int* num_wire_muxes, - int* num_wire_muxes_cb_restricted) { +static std::unique_ptr label_wire_muxes(const int chan_num, + const int seg_num, + const t_chan_seg_details* seg_details, + const int seg_type_index, + const int max_len, + const enum e_direction dir, + const int max_chan_width, + const bool check_cb, + int* num_wire_muxes, + int* num_wire_muxes_cb_restricted) { /* Labels the muxes on that side (seg_num, chan_num, direction). The returned array * maps a label to the actual track #: array[0] = * This routine orders wire muxes by their natural order, i.e. track # @@ -2374,7 +2332,7 @@ static int* label_wire_muxes(const int chan_num, * only looks at segments that belong to the specified segment type. */ int itrack, start, end, num_labels, num_labels_restricted, pass; - int* labels = nullptr; + std::unique_ptr labels; bool is_endpoint; /* COUNT pass then a LOAD pass */ @@ -2383,7 +2341,7 @@ static int* label_wire_muxes(const int chan_num, for (pass = 0; pass < 2; ++pass) { /* Alloc the list on LOAD pass */ if (pass > 0) { - labels = (int*)vtr::malloc(sizeof(int) * num_labels); + labels = std::make_unique(num_labels); num_labels = 0; } @@ -2442,25 +2400,25 @@ static int* label_wire_muxes(const int chan_num, return labels; } -static int* label_incoming_wires(const int chan_num, - const int seg_num, - const int sb_seg, - const t_chan_seg_details* seg_details, - const int max_len, - const enum e_direction dir, - const int max_chan_width, - int* num_incoming_wires, - int* num_ending_wires) { +static std::unique_ptr label_incoming_wires(const int chan_num, + const int seg_num, + const int sb_seg, + const t_chan_seg_details* seg_details, + const int max_len, + const enum e_direction dir, + const int max_chan_width, + int* num_incoming_wires, + int* num_ending_wires) { /* Labels the incoming wires on that side (seg_num, chan_num, direction). * The returned array maps a track # to a label: array[0] = , * the labels 0,1,2,.. identify consecutive incoming wires that have sblock (passing wires with sblock and ending wires) */ int itrack, start, end, i, num_passing, num_ending, pass; - int* labels; bool sblock_exists, is_endpoint; /* Alloc the list of labels for the tracks */ - labels = (int*)vtr::malloc(max_chan_width * sizeof(int)); + auto labels = std::make_unique(max_chan_width); + for (i = 0; i < max_chan_width; ++i) { labels[i] = UN_SET; /* crash hard if unset */ } diff --git a/vpr/src/route/rr_graph2.h b/vpr/src/route/rr_graph2.h index 617730a0df8..393c83cac64 100644 --- a/vpr/src/route/rr_graph2.h +++ b/vpr/src/route/rr_graph2.h @@ -214,9 +214,9 @@ void load_sblock_pattern_lookup(const int i, const enum e_switch_block_type switch_block_type, t_sblock_pattern& sblock_pattern); -int* get_seg_track_counts(const int num_sets, - const std::vector& segment_inf, - const bool use_full_seg_groups); +std::unique_ptr get_seg_track_counts(const int num_sets, + const std::vector& segment_inf, + const bool use_full_seg_groups); void dump_seg_details(const t_chan_seg_details* seg_details, int max_chan_width, From 22824a2364a7523a6eb7fbc65bdad95ab4da3d02 Mon Sep 17 00:00:00 2001 From: Dustin DeWeese Date: Fri, 20 Dec 2019 09:50:09 -0800 Subject: [PATCH 2/3] make format Signed-off-by: Dustin DeWeese --- vpr/src/route/route_timing.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vpr/src/route/route_timing.cpp b/vpr/src/route/route_timing.cpp index cc738162be4..4136c7d7b65 100644 --- a/vpr/src/route/route_timing.cpp +++ b/vpr/src/route/route_timing.cpp @@ -1628,7 +1628,7 @@ static void timing_driven_expand_cheapest(t_heap* cheapest, target_node, router_stats); } else { - //Post-heap prune, do not re-explore from the current/new partial path as it + //Post-heap prune, do not re-explore from the current/new partial path as it //has worse cost than the best partial path to this node found so far VTR_LOGV_DEBUG(f_router_debug, " Worse cost to %d\n", inode); VTR_LOGV_DEBUG(f_router_debug, " Old total cost: %g\n", best_total_cost); From 4ff2a673884f6fda134a42ce3d9ac46753ad547d Mon Sep 17 00:00:00 2001 From: Dustin DeWeese Date: Fri, 20 Dec 2019 10:46:58 -0800 Subject: [PATCH 3/3] clean up some more alloc/free's Signed-off-by: Dustin DeWeese --- vpr/src/route/check_route.cpp | 16 ++++++---------- vpr/src/route/route_common.cpp | 16 ++++++++++------ vpr/src/route/route_timing.cpp | 20 +++++++------------- vpr/src/route/route_tree_timing.cpp | 10 +++++----- 4 files changed, 28 insertions(+), 34 deletions(-) diff --git a/vpr/src/route/check_route.cpp b/vpr/src/route/check_route.cpp index e9fa206736d..baad2a425ae 100644 --- a/vpr/src/route/check_route.cpp +++ b/vpr/src/route/check_route.cpp @@ -42,9 +42,7 @@ void check_route(enum e_route_type route_type) { int max_pins, inode, prev_node; unsigned int ipin; bool valid, connects; - bool* connected_to_route; /* [0 .. device_ctx.rr_nodes.size()-1] */ t_trace* tptr; - bool* pin_done; auto& device_ctx = g_vpr_ctx.device(); auto& cluster_ctx = g_vpr_ctx.clustering(); @@ -70,21 +68,21 @@ void check_route(enum e_route_type route_type) { auto non_configurable_rr_sets = identify_non_configurable_rr_sets(); - connected_to_route = (bool*)vtr::calloc(device_ctx.rr_nodes.size(), sizeof(bool)); + auto connected_to_route = std::make_unique(device_ctx.rr_nodes.size()); + std::fill_n(connected_to_route.get(), device_ctx.rr_nodes.size(), false); max_pins = 0; for (auto net_id : cluster_ctx.clb_nlist.nets()) max_pins = std::max(max_pins, (int)cluster_ctx.clb_nlist.net_pins(net_id).size()); - pin_done = (bool*)vtr::malloc(max_pins * sizeof(bool)); + auto pin_done = std::make_unique(max_pins); /* Now check that all nets are indeed connected. */ for (auto net_id : cluster_ctx.clb_nlist.nets()) { if (cluster_ctx.clb_nlist.net_is_ignored(net_id) || cluster_ctx.clb_nlist.net_sinks(net_id).size() == 0) /* Skip ignored nets. */ continue; - for (ipin = 0; ipin < cluster_ctx.clb_nlist.net_pins(net_id).size(); ipin++) - pin_done[ipin] = false; + std::fill_n(pin_done.get(), cluster_ctx.clb_nlist.net_pins(net_id).size(), false); /* Check the SOURCE of the net. */ tptr = route_ctx.trace[net_id].head; @@ -132,7 +130,7 @@ void check_route(enum e_route_type route_type) { connected_to_route[inode] = true; /* Mark as in path. */ if (device_ctx.rr_nodes[inode].type() == SINK) { - check_sink(inode, net_id, pin_done); + check_sink(inode, net_id, pin_done.get()); num_sinks += 1; } @@ -160,12 +158,10 @@ void check_route(enum e_route_type route_type) { check_net_for_stubs(net_id); - reset_flags(net_id, connected_to_route); + reset_flags(net_id, connected_to_route.get()); } /* End for each net */ - free(pin_done); - free(connected_to_route); VTR_LOG("Completed routing consistency check successfully.\n"); VTR_LOG("\n"); } diff --git a/vpr/src/route/route_common.cpp b/vpr/src/route/route_common.cpp index 6204dad984b..a99663c1fb9 100644 --- a/vpr/src/route/route_common.cpp +++ b/vpr/src/route/route_common.cpp @@ -44,9 +44,9 @@ struct t_trace_branch { /**************** Static variables local to route_common.c ******************/ -static t_heap** heap; /* Indexed from [1..heap_size] */ -static int heap_size; /* Number of slots in the heap array */ -static int heap_tail; /* Index of first unused slot in the heap array */ +static t_heap** heap = nullptr; /* Indexed from [1..heap_size] */ +static int heap_size; /* Number of slots in the heap array */ +static int heap_tail; /* Index of first unused slot in the heap array */ /* For managing my own list of currently free heap data structures. */ static t_heap* heap_free_head = nullptr; @@ -467,14 +467,18 @@ void pathfinder_update_cost(float pres_fac, float acc_fac) { } } +// Note: malloc()/free() must be used for the heap, +// or realloc() must be eliminated from add_to_heap() +// because there is no C++ equivalent. void init_heap(const DeviceGrid& grid) { if (heap != nullptr) { vtr::free(heap + 1); - heap = nullptr; } + heap_size = (grid.width() - 1) * (grid.height() - 1); - heap = (t_heap**)vtr::malloc(heap_size * sizeof(t_heap*)); - heap--; /* heap stores from [1..heap_size] */ + + // heap stores from [1..heap_size] + heap = (t_heap**)vtr::malloc(heap_size * sizeof(t_heap*)) - 1; heap_tail = 1; } diff --git a/vpr/src/route/route_timing.cpp b/vpr/src/route/route_timing.cpp index 4136c7d7b65..b5d9ea50dda 100644 --- a/vpr/src/route/route_timing.cpp +++ b/vpr/src/route/route_timing.cpp @@ -838,17 +838,11 @@ void alloc_timing_driven_route_structs(float** pin_criticality_ptr, t_rt_node*** rt_node_of_sink_ptr) { /* Allocates all the structures needed only by the timing-driven router. */ - int max_pins_per_net = get_max_pins_per_net(); - int max_sinks = std::max(max_pins_per_net - 1, 0); + int max_sinks = std::max(get_max_pins_per_net() - 1, 0); - float* pin_criticality = (float*)vtr::malloc(max_sinks * sizeof(float)); - *pin_criticality_ptr = pin_criticality - 1; /* First sink is pin #1. */ - - int* sink_order = (int*)vtr::malloc(max_sinks * sizeof(int)); - *sink_order_ptr = sink_order - 1; - - t_rt_node** rt_node_of_sink = (t_rt_node**)vtr::malloc(max_sinks * sizeof(t_rt_node*)); - *rt_node_of_sink_ptr = rt_node_of_sink - 1; + *pin_criticality_ptr = new float[max_sinks] - 1; /* First sink is pin #1. */ + *sink_order_ptr = new int[max_sinks] - 1; + *rt_node_of_sink_ptr = new t_rt_node*[max_sinks] - 1; alloc_route_tree_timing_structs(); } @@ -861,11 +855,11 @@ void free_timing_driven_route_structs(float* pin_criticality, int* sink_order, t /* Frees all the stuctures needed only by the timing-driven router. */ // coverity[offset_free : Intentional] - free(pin_criticality + 1); /* Starts at index 1. */ + delete[](pin_criticality + 1); /* Starts at index 1. */ // coverity[offset_free : Intentional] - free(sink_order + 1); + delete[](sink_order + 1); // coverity[offset_free : Intentional] - free(rt_node_of_sink + 1); + delete[](rt_node_of_sink + 1); free_route_tree_timing_structs(); } diff --git a/vpr/src/route/route_tree_timing.cpp b/vpr/src/route/route_tree_timing.cpp index 7988d02dcb6..ecd171b514e 100644 --- a/vpr/src/route/route_tree_timing.cpp +++ b/vpr/src/route/route_tree_timing.cpp @@ -91,7 +91,7 @@ bool alloc_route_tree_timing_structs(bool exists_ok) { void free_route_tree_timing_structs() { /* Frees the structures needed to build routing trees, and really frees - * (i.e. calls free) all the data on the free lists. */ + * (i.e. deletes) all the data on the free lists. */ t_rt_node *rt_node, *next_node; t_linked_rt_edge *rt_edge, *next_edge; @@ -102,7 +102,7 @@ void free_route_tree_timing_structs() { while (rt_node != nullptr) { next_node = rt_node->u.next; - free(rt_node); + delete rt_node; rt_node = next_node; } @@ -112,7 +112,7 @@ void free_route_tree_timing_structs() { while (rt_edge != nullptr) { next_edge = rt_edge->next; - free(rt_edge); + delete rt_edge; rt_edge = next_edge; } @@ -131,7 +131,7 @@ alloc_rt_node() { if (rt_node != nullptr) { rt_node_free_list = rt_node->u.next; } else { - rt_node = (t_rt_node*)vtr::malloc(sizeof(t_rt_node)); + rt_node = new t_rt_node; } return (rt_node); @@ -156,7 +156,7 @@ alloc_linked_rt_edge() { if (linked_rt_edge != nullptr) { rt_edge_free_list = linked_rt_edge->next; } else { - linked_rt_edge = (t_linked_rt_edge*)vtr::malloc(sizeof(t_linked_rt_edge)); + linked_rt_edge = new t_linked_rt_edge; } VTR_ASSERT(linked_rt_edge != nullptr);