Skip to content

Commit 30b655c

Browse files
[Warnings] Changed C String to STD String
GCC sometimes gets confused with how strings are allocated, when they are C strings allocated by hand. Changed to an std string since it is easier to work with and removes the warning.
1 parent 601017b commit 30b655c

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

vpr/src/power/power.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ static void power_usage_primitive(t_power_usage* power_usage, t_pb* pb, t_pb_gra
138138
if (strcmp(pb_graph_node->pb_type->blif_model, MODEL_NAMES) == 0) {
139139
/* LUT */
140140

141-
char* SRAM_values;
141+
std::string SRAM_values;
142142
float* input_probabilities;
143143
float* input_densities;
144144
int LUT_size;
@@ -174,7 +174,6 @@ static void power_usage_primitive(t_power_usage* power_usage, t_pb* pb, t_pb_gra
174174
power_ctx.arch->LUT_transistor_size, SRAM_values,
175175
input_probabilities, input_densities, power_ctx.solution_inf.T_crit);
176176
power_add_usage(power_usage, &sub_power_usage);
177-
delete[] SRAM_values;
178177
delete[] input_probabilities;
179178
delete[] input_densities;
180179
} else if (strcmp(pb_graph_node->pb_type->blif_model, MODEL_LATCH) == 0) {

vpr/src/power/power_components.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
/************************* INCLUDES *********************************/
2424
#include <cstring>
2525
#include <cmath>
26+
#include <string>
2627

2728
#include "vtr_math.h"
2829
#include "vtr_assert.h"
@@ -203,7 +204,7 @@ void power_usage_ff(t_power_usage* power_usage, float size, float D_prob, float
203204
* 7 _Z_|
204205
*
205206
*/
206-
void power_usage_lut(t_power_usage* power_usage, int lut_size, float transistor_size, char* SRAM_values, float* input_prob, float* input_dens, float period) {
207+
void power_usage_lut(t_power_usage* power_usage, int lut_size, float transistor_size, std::string SRAM_values, float* input_prob, float* input_dens, float period) {
207208
float** internal_prob;
208209
float** internal_dens;
209210
float** internal_v;

vpr/src/power/power_components.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#define __POWER_COMPONENTS_H__
2525

2626
/************************* INCLUDES *********************************/
27+
#include <string>
2728
#include "power.h"
2829
#include "clustered_netlist.h"
2930

@@ -82,7 +83,7 @@ void power_component_add_usage(t_power_usage* power_usage,
8283
float power_component_get_usage_sum(e_power_component_type component_idx);
8384

8485
void power_usage_ff(t_power_usage* power_usage, float size, float D_prob, float D_dens, float Q_prob, float Q_dens, float clk_prob, float clk_dens, float period);
85-
void power_usage_lut(t_power_usage* power_usage, int LUT_size, float transistor_size, char* SRAM_values, float* input_densities, float* input_probabilities, float period);
86+
void power_usage_lut(t_power_usage* power_usage, int LUT_size, float transistor_size, std::string SRAM_values, float* input_densities, float* input_probabilities, float period);
8687
void power_usage_local_interc_mux(t_power_usage* power_usage, t_pb* pb, t_interconnect_pins* interc_pins, ClusterBlockId iblk);
8788
void power_usage_mux_multilevel(t_power_usage* power_usage,
8889
t_mux_arch* mux_arch,

vpr/src/power/power_util.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <cstring>
2424
#include <cmath>
2525
#include <map>
26+
#include <string>
2627

2728
#include "vtr_assert.h"
2829
#include "vtr_memory.h"
@@ -211,16 +212,13 @@ float calc_buffer_stage_effort(int N, float final_stage_size) {
211212
* - LUT_size: The number of LUT inputs
212213
* - truth_table: The logic terms saved from the BLIF file
213214
*/
214-
char* alloc_SRAM_values_from_truth_table(int LUT_size,
215-
const AtomNetlist::TruthTable& truth_table) {
215+
std::string alloc_SRAM_values_from_truth_table(int LUT_size,
216+
const AtomNetlist::TruthTable& truth_table) {
216217
size_t num_SRAM_bits = 1 << LUT_size;
217218

218219
//SRAM value stored as a string of '0' and '1' characters
219220
// Initialize to all zeros
220-
char* SRAM_values = new char[num_SRAM_bits + 1];
221-
for (size_t i = 0; i < num_SRAM_bits + 1; i++)
222-
SRAM_values[i] = '0';
223-
SRAM_values[num_SRAM_bits] = '\0';
221+
std::string SRAM_values(num_SRAM_bits, '0');
224222

225223
if (truth_table.empty()) {
226224
for (size_t i = 0; i < num_SRAM_bits; i++) {

vpr/src/power/power_util.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#define __POWER_UTIL_H__
2424

2525
/************************* INCLUDES *********************************/
26+
#include <string>
2627
#include "power.h"
2728
#include "power_components.h"
2829
#include "atom_netlist.h"
@@ -63,8 +64,8 @@ bool power_method_is_transistor_level(e_power_estimation_method estimation_metho
6364
bool power_method_is_recursive(e_power_estimation_method method);
6465

6566
const char* transistor_type_name(e_tx_type type);
66-
char* alloc_SRAM_values_from_truth_table(int LUT_size,
67-
const AtomNetlist::TruthTable& truth_table);
67+
std::string alloc_SRAM_values_from_truth_table(int LUT_size,
68+
const AtomNetlist::TruthTable& truth_table);
6869
float clb_net_density(ClusterNetId net_idx);
6970
const char* interconnect_type_name(enum e_interconnect type);
7071
float clb_net_prob(ClusterNetId net_idx);

0 commit comments

Comments
 (0)