Skip to content

Commit 74650bb

Browse files
committed
[Libs]: - Free "meta" leftover pointer in grid_def_loc struct
- Free arch struct created by read_arch and write_arch_bb routines Signed-off-by: Seyed Alireza Damghani <[email protected]>
1 parent e8c0d23 commit 74650bb

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

libs/libarchfpga/src/arch_util.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,10 @@ void free_arch(t_arch* arch) {
171171

172172
vtr::free(arch->architecture_id);
173173

174+
for(t_grid_def& grid_def : arch->grid_layouts)
175+
for(t_grid_loc_def& grid_loc_def : grid_def.loc_defs)
176+
vtr::free(grid_loc_def.meta);
177+
174178
if (arch->model_library) {
175179
for (int i = 0; i < 4; ++i) {
176180
vtr::t_linked_vptr* vptr = arch->model_library[i].pb_types;

libs/libarchfpga/src/main.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "vtr_error.h"
1313
#include "vtr_memory.h"
1414

15+
#include "arch_util.h"
1516
#include "read_xml_arch_file.h"
1617
#include "echo_arch.h"
1718

@@ -48,7 +49,13 @@ int main(int argc, char** argv) {
4849
printf("Printing Results\n");
4950

5051
EchoArch(argv[3], physical_tile_types, logical_block_types, arch);
51-
free(arch);
52+
53+
// CLEAN UP
54+
free_arch(arch);
55+
vtr::free(arch);
56+
free_type_descriptors(physical_tile_types);
57+
free_type_descriptors(logical_block_types);
58+
5259
} catch (vtr::VtrError& vtr_error) {
5360
printf("Failed to process architecture %s: %s\n", argv[1], vtr_error.what());
5461
return 1;

libs/libarchfpga/src/write_arch_bb.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "vtr_error.h"
1414
#include "vtr_memory.h"
1515

16+
#include "arch_util.h"
1617
#include "read_xml_arch_file.h"
1718
#include "write_models_bb.h"
1819

@@ -48,7 +49,13 @@ int main(int argc, char** argv) {
4849
printf("Printing Results ...\n");
4950

5051
WriteModels_bb(argv[1], argv[2], arch);
51-
free(arch);
52+
53+
// CLEAN UP
54+
free_arch(arch);
55+
vtr::free(arch);
56+
free_type_descriptors(physical_tile_types);
57+
free_type_descriptors(logical_block_types);
58+
5259
} catch (vtr::VtrError& vtr_error) {
5360
printf("Failed to process architecture %s: %s\n", argv[1], vtr_error.what());
5461
return 1;

0 commit comments

Comments
 (0)