@@ -163,7 +163,7 @@ void free_arch(t_arch* arch) {
163163 vtr::free (arch->architecture_id );
164164
165165 if (arch->clocks ) {
166- vtr::free ( arch->clocks ->clock_inf ) ;
166+ delete[] arch->clocks ->clock_inf ;
167167 }
168168
169169 delete (arch->noc );
@@ -336,16 +336,16 @@ static void free_pb_type(t_pb_type* pb_type) {
336336 vtr::free (pb_type->modes [i].interconnect [j].annotations [k].value [m]);
337337 }
338338 delete[] pb_type->modes [i].interconnect [j].annotations [k].prop ;
339- vtr::free ( pb_type->modes [i].interconnect [j].annotations [k].value ) ;
339+ delete[] pb_type->modes [i].interconnect [j].annotations [k].value ;
340340 }
341- vtr::free ( pb_type->modes [i].interconnect [j].annotations ) ;
341+ delete[] pb_type->modes [i].interconnect [j].annotations ;
342342 if (pb_type->modes [i].interconnect [j].interconnect_power )
343- vtr::free ( pb_type->modes [i].interconnect [j].interconnect_power ) ;
343+ delete pb_type->modes [i].interconnect [j].interconnect_power ;
344344 }
345345 if (pb_type->modes [i].interconnect )
346346 delete[] pb_type->modes [i].interconnect ;
347347 if (pb_type->modes [i].mode_power )
348- vtr::free (pb_type->modes [i].mode_power );
348+ delete (pb_type->modes [i].mode_power );
349349 }
350350 if (pb_type->modes )
351351 delete[] pb_type->modes ;
@@ -354,7 +354,7 @@ static void free_pb_type(t_pb_type* pb_type) {
354354 for (int j = 0 ; j < pb_type->annotations [i].num_value_prop_pairs ; ++j) {
355355 vtr::free (pb_type->annotations [i].value [j]);
356356 }
357- vtr::free ( pb_type->annotations [i].value ) ;
357+ delete[] pb_type->annotations [i].value ;
358358 delete[] pb_type->annotations [i].prop ;
359359 if (pb_type->annotations [i].input_pins ) {
360360 vtr::free (pb_type->annotations [i].input_pins );
@@ -371,7 +371,7 @@ static void free_pb_type(t_pb_type* pb_type) {
371371 }
372372
373373 if (pb_type->pb_type_power ) {
374- vtr::free ( pb_type->pb_type_power ) ;
374+ delete pb_type->pb_type_power ;
375375 }
376376
377377 for (int i = 0 ; i < pb_type->num_ports ; ++i) {
@@ -380,10 +380,10 @@ static void free_pb_type(t_pb_type* pb_type) {
380380 vtr::free (pb_type->ports [i].port_class );
381381 }
382382 if (pb_type->ports [i].port_power ) {
383- vtr::free ( pb_type->ports [i].port_power ) ;
383+ delete pb_type->ports [i].port_power ;
384384 }
385385 }
386- vtr::free ( pb_type->ports ) ;
386+ delete[] pb_type->ports ;
387387}
388388
389389t_port* findPortByName (const char * name, t_pb_type* pb_type, int * high_index, int * low_index) {
@@ -495,13 +495,12 @@ void alloc_and_load_default_child_for_pb_type(t_pb_type* pb_type,
495495 copy->num_pb = 1 ;
496496
497497 /* Power */
498- copy->pb_type_power = (t_pb_type_power*)vtr::calloc (1 ,
499- sizeof (t_pb_type_power));
498+ copy->pb_type_power = new t_pb_type_power ();
500499 copy->pb_type_power ->estimation_method = power_method_inherited (pb_type->pb_type_power ->estimation_method );
501500
502501 /* Ports */
503502 copy->num_ports = pb_type->num_ports ;
504- copy->ports = ( t_port*) vtr::calloc ( pb_type->num_ports , sizeof (t_port) );
503+ copy->ports = new t_port[ pb_type->num_ports ]( );
505504 for (i = 0 ; i < pb_type->num_ports ; i++) {
506505 copy->ports [i].is_clock = pb_type->ports [i].is_clock ;
507506 copy->ports [i].model_port = pb_type->ports [i].model_port ;
@@ -514,8 +513,7 @@ void alloc_and_load_default_child_for_pb_type(t_pb_type* pb_type,
514513 copy->ports [i].index = pb_type->ports [i].index ;
515514 copy->ports [i].absolute_first_pin_index = pb_type->ports [i].absolute_first_pin_index ;
516515
517- copy->ports [i].port_power = (t_port_power*)vtr::calloc (1 ,
518- sizeof (t_port_power));
516+ copy->ports [i].port_power = new t_port_power ();
519517 // Defaults
520518 if (copy->pb_type_power ->estimation_method == POWER_METHOD_AUTO_SIZES) {
521519 copy->ports [i].port_power ->wire_type = POWER_WIRE_TYPE_AUTO;
@@ -550,7 +548,7 @@ void alloc_and_load_default_child_for_pb_type(t_pb_type* pb_type,
550548 copy->annotations [i].type = pb_type->annotations [i].type ;
551549 copy->annotations [i].num_value_prop_pairs = pb_type->annotations [i].num_value_prop_pairs ;
552550 copy->annotations [i].prop = new int [pb_type->annotations [i].num_value_prop_pairs ];
553- copy->annotations [i].value = ( char **) vtr::malloc ( sizeof ( char *) * pb_type->annotations [i].num_value_prop_pairs ) ;
551+ copy->annotations [i].value = new char *[ pb_type->annotations [i].num_value_prop_pairs ] ;
554552 for (j = 0 ; j < pb_type->annotations [i].num_value_prop_pairs ; j++) {
555553 copy->annotations [i].prop [j] = pb_type->annotations [i].prop [j];
556554 copy->annotations [i].value [j] = vtr::strdup (pb_type->annotations [i].value [j]);
@@ -580,8 +578,7 @@ void ProcessLutClass(t_pb_type* lut_pb_type) {
580578 lut_pb_type->modes [0 ].parent_pb_type = lut_pb_type;
581579 lut_pb_type->modes [0 ].index = 0 ;
582580 lut_pb_type->modes [0 ].num_pb_type_children = 0 ;
583- lut_pb_type->modes [0 ].mode_power = (t_mode_power*)vtr::calloc (1 ,
584- sizeof (t_mode_power));
581+ lut_pb_type->modes [0 ].mode_power = new t_mode_power ();
585582
586583 /* Process interconnect */
587584 /* TODO: add timing annotations to route-through */
@@ -613,10 +610,9 @@ void ProcessLutClass(t_pb_type* lut_pb_type) {
613610
614611 lut_pb_type->modes [0 ].interconnect [0 ].parent_mode_index = 0 ;
615612 lut_pb_type->modes [0 ].interconnect [0 ].parent_mode = &lut_pb_type->modes [0 ];
616- lut_pb_type->modes [0 ].interconnect [0 ].interconnect_power = (t_interconnect_power*) vtr::calloc ( 1 , sizeof ( t_interconnect_power) );
613+ lut_pb_type->modes [0 ].interconnect [0 ].interconnect_power = new t_interconnect_power ( );
617614
618- lut_pb_type->modes [0 ].interconnect [0 ].annotations = (t_pin_to_pin_annotation*)vtr::calloc (lut_pb_type->num_annotations ,
619- sizeof (t_pin_to_pin_annotation));
615+ lut_pb_type->modes [0 ].interconnect [0 ].annotations = new t_pin_to_pin_annotation[lut_pb_type->num_annotations ]();
620616 lut_pb_type->modes [0 ].interconnect [0 ].num_annotations = lut_pb_type->num_annotations ;
621617 for (i = 0 ; i < lut_pb_type->modes [0 ].interconnect [0 ].num_annotations ;
622618 i++) {
@@ -628,8 +624,7 @@ void ProcessLutClass(t_pb_type* lut_pb_type) {
628624 lut_pb_type->modes [0 ].interconnect [0 ].annotations [i].type = lut_pb_type->annotations [i].type ;
629625 lut_pb_type->modes [0 ].interconnect [0 ].annotations [i].num_value_prop_pairs = lut_pb_type->annotations [i].num_value_prop_pairs ;
630626 lut_pb_type->modes [0 ].interconnect [0 ].annotations [i].prop = new int [lut_pb_type->annotations [i].num_value_prop_pairs ];
631- lut_pb_type->modes [0 ].interconnect [0 ].annotations [i].value = (char **)vtr::malloc (sizeof (char *)
632- * lut_pb_type->annotations [i].num_value_prop_pairs );
627+ lut_pb_type->modes [0 ].interconnect [0 ].annotations [i].value = new char *[lut_pb_type->annotations [i].num_value_prop_pairs ];
633628 for (j = 0 ; j < lut_pb_type->annotations [i].num_value_prop_pairs ; j++) {
634629 lut_pb_type->modes [0 ].interconnect [0 ].annotations [i].prop [j] = lut_pb_type->annotations [i].prop [j];
635630 lut_pb_type->modes [0 ].interconnect [0 ].annotations [i].value [j] = vtr::strdup (lut_pb_type->annotations [i].value [j]);
@@ -642,26 +637,25 @@ void ProcessLutClass(t_pb_type* lut_pb_type) {
642637 lut_pb_type->modes [1 ].parent_pb_type = lut_pb_type;
643638 lut_pb_type->modes [1 ].index = 1 ;
644639 lut_pb_type->modes [1 ].num_pb_type_children = 1 ;
645- lut_pb_type->modes [1 ].mode_power = (t_mode_power*)vtr::calloc (1 ,
646- sizeof (t_mode_power));
640+ lut_pb_type->modes [1 ].mode_power = new t_mode_power ();
647641 lut_pb_type->modes [1 ].pb_type_children = new t_pb_type[1 ];
648642 alloc_and_load_default_child_for_pb_type (lut_pb_type, default_name,
649643 lut_pb_type->modes [1 ].pb_type_children );
650644 /* moved annotations to child so delete old annotations */
651645 for (i = 0 ; i < lut_pb_type->num_annotations ; i++) {
652646 for (j = 0 ; j < lut_pb_type->annotations [i].num_value_prop_pairs ; j++) {
653- free (lut_pb_type->annotations [i].value [j]);
647+ vtr:: free (lut_pb_type->annotations [i].value [j]);
654648 }
655- free ( lut_pb_type->annotations [i].value ) ;
649+ delete[] lut_pb_type->annotations [i].value ;
656650 delete[] lut_pb_type->annotations [i].prop ;
657651 if (lut_pb_type->annotations [i].input_pins ) {
658- free (lut_pb_type->annotations [i].input_pins );
652+ vtr:: free (lut_pb_type->annotations [i].input_pins );
659653 }
660654 if (lut_pb_type->annotations [i].output_pins ) {
661- free (lut_pb_type->annotations [i].output_pins );
655+ vtr:: free (lut_pb_type->annotations [i].output_pins );
662656 }
663657 if (lut_pb_type->annotations [i].clock ) {
664- free (lut_pb_type->annotations [i].clock );
658+ vtr:: free (lut_pb_type->annotations [i].clock );
665659 }
666660 }
667661 lut_pb_type->num_annotations = 0 ;
@@ -693,7 +687,7 @@ void ProcessLutClass(t_pb_type* lut_pb_type) {
693687
694688 lut_pb_type->modes [1 ].interconnect [0 ].parent_mode_index = 1 ;
695689 lut_pb_type->modes [1 ].interconnect [0 ].parent_mode = &lut_pb_type->modes [1 ];
696- lut_pb_type->modes [1 ].interconnect [0 ].interconnect_power = (t_interconnect_power*) vtr::calloc ( 1 , sizeof ( t_interconnect_power) );
690+ lut_pb_type->modes [1 ].interconnect [0 ].interconnect_power = new t_interconnect_power ( );
697691
698692 lut_pb_type->modes [1 ].interconnect [1 ].name = (char *)vtr::calloc (strlen (lut_pb_type->name ) + 11 , sizeof (char ));
699693 sprintf (lut_pb_type->modes [1 ].interconnect [1 ].name , " direct:%s" ,
@@ -712,7 +706,7 @@ void ProcessLutClass(t_pb_type* lut_pb_type) {
712706
713707 lut_pb_type->modes [1 ].interconnect [1 ].parent_mode_index = 1 ;
714708 lut_pb_type->modes [1 ].interconnect [1 ].parent_mode = &lut_pb_type->modes [1 ];
715- lut_pb_type->modes [1 ].interconnect [1 ].interconnect_power = (t_interconnect_power*) vtr::calloc ( 1 , sizeof ( t_interconnect_power) );
709+ lut_pb_type->modes [1 ].interconnect [1 ].interconnect_power = new t_interconnect_power ( );
716710
717711 free (default_name);
718712
@@ -737,8 +731,7 @@ void ProcessMemoryClass(t_pb_type* mem_pb_type) {
737731 mem_pb_type->modes [0 ].name = vtr::strdup (default_name);
738732 mem_pb_type->modes [0 ].parent_pb_type = mem_pb_type;
739733 mem_pb_type->modes [0 ].index = 0 ;
740- mem_pb_type->modes [0 ].mode_power = (t_mode_power*)vtr::calloc (1 ,
741- sizeof (t_mode_power));
734+ mem_pb_type->modes [0 ].mode_power = new t_mode_power ();
742735 num_pb = OPEN;
743736 for (i = 0 ; i < mem_pb_type->num_ports ; i++) {
744737 if (mem_pb_type->ports [i].port_class != nullptr
@@ -834,8 +827,7 @@ void ProcessMemoryClass(t_pb_type* mem_pb_type) {
834827 }
835828
836829 /* Allocate interconnect power structures */
837- mem_pb_type->modes [0 ].interconnect [i_inter].interconnect_power = (t_interconnect_power*)vtr::calloc (1 ,
838- sizeof (t_interconnect_power));
830+ mem_pb_type->modes [0 ].interconnect [i_inter].interconnect_power = new t_interconnect_power ();
839831 i_inter++;
840832 } else {
841833 for (j = 0 ; j < num_pb; j++) {
@@ -875,8 +867,7 @@ void ProcessMemoryClass(t_pb_type* mem_pb_type) {
875867 }
876868
877869 /* Allocate interconnect power structures */
878- mem_pb_type->modes [0 ].interconnect [i_inter].interconnect_power = (t_interconnect_power*)vtr::calloc (1 ,
879- sizeof (t_interconnect_power));
870+ mem_pb_type->modes [0 ].interconnect [i_inter].interconnect_power = new t_interconnect_power ();
880871 i_inter++;
881872 }
882873 }
0 commit comments