Skip to content

Commit 9de62d4

Browse files
[Warnings] Simplified String Allocation
GCC sometimes gets confused with how strings are allocated, when they are C strings allocated by hand. Tried to simplify the allocation to make it more obvious. In the future this should be replaced with a vector.
1 parent 601017b commit 9de62d4

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

vpr/src/power/power_util.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,11 @@ char* alloc_SRAM_values_from_truth_table(int LUT_size,
217217

218218
//SRAM value stored as a string of '0' and '1' characters
219219
// Initialize to all zeros
220-
char* SRAM_values = new char[num_SRAM_bits + 1];
220+
size_t SRAM_values_str_size = num_SRAM_bits + 1;
221+
char* SRAM_values = new char[SRAM_values_str_size];
221222
for (size_t i = 0; i < num_SRAM_bits + 1; i++)
222223
SRAM_values[i] = '0';
223-
SRAM_values[num_SRAM_bits] = '\0';
224+
SRAM_values[SRAM_values_str_size - 1] = '\0';
224225

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

0 commit comments

Comments
 (0)