@@ -357,7 +357,7 @@ static void ProcessPower(pugi::xml_node parent,
357357 t_power_arch* power_arch,
358358 const pugiutil::loc_data& loc_data);
359359
360- static void ProcessClocks (pugi::xml_node Parent, t_clock_arch* clocks, const pugiutil::loc_data& loc_data);
360+ static void ProcessClocks (pugi::xml_node Parent, std::vector<t_clock_network>& clocks, const pugiutil::loc_data& loc_data);
361361
362362static void ProcessPb_TypePowerEstMethod (pugi::xml_node Parent, t_pb_type* pb_type, const pugiutil::loc_data& loc_data);
363363static void ProcessPb_TypePort_Power (pugi::xml_node Parent, t_port* port, e_power_estimation_method power_method, const pugiutil::loc_data& loc_data);
@@ -527,15 +527,13 @@ void XmlReadArch(const char* ArchFile,
527527 Next = get_single_child (architecture, " clocks" , loc_data, POWER_REQD);
528528 if (Next) {
529529 if (arch->clocks ) {
530- ProcessClocks (Next, arch->clocks , loc_data);
530+ ProcessClocks (Next, * arch->clocks , loc_data);
531531 } else {
532532 /* This information still needs to be read, even if it is just
533533 * thrown away.
534534 */
535- t_clock_arch* clocks_fake = new t_clock_arch () ;
535+ std::vector<t_clock_network> clocks_fake;
536536 ProcessClocks (Next, clocks_fake, loc_data);
537- delete[] clocks_fake->clock_inf ;
538- delete clocks_fake;
539537 }
540538 }
541539
@@ -4712,32 +4710,26 @@ static void ProcessPower(pugi::xml_node parent,
47124710}
47134711
47144712/* Get the clock architecture */
4715- static void ProcessClocks (pugi::xml_node Parent, t_clock_arch* clocks, const pugiutil::loc_data& loc_data) {
4713+ static void ProcessClocks (pugi::xml_node Parent, std::vector<t_clock_network>& clocks, const pugiutil::loc_data& loc_data) {
47164714 pugi::xml_node Node;
47174715 const char * tmp;
47184716
4719- clocks-> num_global_clocks = count_children (Parent, " clock" , loc_data, ReqOpt::OPTIONAL);
4717+ int num_global_clocks = count_children (Parent, " clock" , loc_data, ReqOpt::OPTIONAL);
47204718
4721- /* Alloc the clockdetails */
4722- clocks->clock_inf = nullptr ;
4723- if (clocks->num_global_clocks > 0 ) {
4724- clocks->clock_inf = new t_clock_network[clocks->num_global_clocks ];
4725- memset (clocks->clock_inf , 0 ,
4726- clocks->num_global_clocks * sizeof (t_clock_network));
4727- }
4719+ clocks.resize (num_global_clocks, t_clock_network ());
47284720
47294721 /* Load the clock info. */
47304722 Node = get_first_child (Parent, " clock" , loc_data);
4731- for (int i = 0 ; i < clocks-> num_global_clocks ; ++i) {
4723+ for (int i = 0 ; i < num_global_clocks; ++i) {
47324724 tmp = get_attribute (Node, " buffer_size" , loc_data).value ();
47334725 if (strcmp (tmp, " auto" ) == 0 ) {
4734- clocks-> clock_inf [i].autosize_buffer = true ;
4726+ clocks[i].autosize_buffer = true ;
47354727 } else {
4736- clocks-> clock_inf [i].autosize_buffer = false ;
4737- clocks-> clock_inf [i].buffer_size = (float )atof (tmp);
4728+ clocks[i].autosize_buffer = false ;
4729+ clocks[i].buffer_size = (float )atof (tmp);
47384730 }
47394731
4740- clocks-> clock_inf [i].C_wire = get_attribute (Node, " C_wire" , loc_data).as_float (0 );
4732+ clocks[i].C_wire = get_attribute (Node, " C_wire" , loc_data).as_float (0 );
47414733
47424734 /* get the next clock item */
47434735 Node = Node.next_sibling (Node.name ());
0 commit comments