Skip to content

Commit 035e094

Browse files
authored
Merge pull request #875 from CAS-Atlantic/odin_ipo_leak_fix
Odin_II: fix leak appearing when IPO is enabled
2 parents d720d59 + d94d879 commit 035e094

File tree

2 files changed

+8
-15
lines changed

2 files changed

+8
-15
lines changed

ODIN_II/SRC/adders.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,10 @@ void init_split_adder(nnode_t *node, nnode_t *ptr, int a, int sizea, int b, int
6767
*-------------------------------------------------------------------------*/
6868
void init_add_distribution()
6969
{
70-
int i, j;
7170
oassert(hard_adders != NULL);
72-
j = hard_adders->inputs->size + hard_adders->inputs->next->size;
73-
adder = (int *)vtr::malloc(sizeof(int) * (j + 1));
74-
for (i = 0; i <= j; i++)
75-
adder[i] = 0;
76-
return;
71+
72+
int len = hard_adders->inputs->size + hard_adders->inputs->next->size + 1;
73+
adder = (int *)vtr::calloc(len, sizeof(int));
7774
}
7875

7976
/*---------------------------------------------------------------------------
@@ -121,7 +118,7 @@ void report_add_distribution()
121118
printf("\n");
122119
printf("\nGeometric mean adder/subtractor chain length: %.2f\n", geomean_addsub_length);
123120

124-
return;
121+
vtr::free(adder);
125122
}
126123

127124
/*---------------------------------------------------------------------------

ODIN_II/SRC/multipliers.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ int min_mult = 0;
5252
int *mults = NULL;
5353

5454
void record_mult_distribution(nnode_t *node);
55+
void terminate_mult_distribution();
5556
void init_split_multiplier(nnode_t *node, nnode_t *ptr, int offa, int a, int offb, int b, nnode_t *node_a, nnode_t *node_b);
5657
void init_multiplier_adder(nnode_t *node, nnode_t *parent, int a, int b);
5758
void split_multiplier_a(nnode_t *node, int a0, int a1, int b);
@@ -275,14 +276,9 @@ void instantiate_simple_soft_multiplier(nnode_t *node, short mark, netlist_t *ne
275276
*-------------------------------------------------------------------------*/
276277
void init_mult_distribution()
277278
{
278-
int i, j;
279-
280279
oassert(hard_multipliers != NULL);
281-
mults = (int *)vtr::malloc(sizeof(int) * (hard_multipliers->inputs->size + 1) * (1 + hard_multipliers->inputs->next->size));
282-
for (i = 0; i <= hard_multipliers->inputs->size; i++)
283-
for (j = 0; j <= hard_multipliers->inputs->next->size; j++)
284-
mults[i * hard_multipliers->inputs->size + j] = 0;
285-
return;
280+
int len = ( 1 + hard_multipliers->inputs->size ) * ( 1 + hard_multipliers->inputs->next->size );
281+
mults = (int *)vtr::calloc(len, sizeof(int));
286282
}
287283

288284
/*---------------------------------------------------------------------------
@@ -327,7 +323,7 @@ void report_mult_distribution()
327323
}
328324
printf("\n");
329325
printf("\nTotal # of multipliers = %ld\n", num_total);
330-
return;
326+
vtr::free(mults);
331327
}
332328

333329
/*---------------------------------------------------------------------------

0 commit comments

Comments
 (0)