From 5a04da2082563d2b1d3e7469dfce1d37831f6942 Mon Sep 17 00:00:00 2001 From: tangxifan Date: Tue, 7 Apr 2020 16:14:41 -0600 Subject: [PATCH] fix memory leakage in openfpga title --- openfpga/src/base/openfpga_title.cpp | 4 ++-- openfpga/src/base/openfpga_title.h | 2 +- openfpga/src/main.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/openfpga/src/base/openfpga_title.cpp b/openfpga/src/base/openfpga_title.cpp index 41616c8bd..ca39fe2e6 100644 --- a/openfpga/src/base/openfpga_title.cpp +++ b/openfpga/src/base/openfpga_title.cpp @@ -8,7 +8,7 @@ * Generate a string of openfpga title introduction * This is mainly used when launching OpenFPGA shell *******************************************************************/ -const char* create_openfpga_title() { +std::string create_openfpga_title() { std::string title; title += std::string("\n"); @@ -49,5 +49,5 @@ const char* create_openfpga_title() { title += std::string("THE SOFTWARE.\n"); title += std::string("\n"); - return title.c_str(); + return title; } diff --git a/openfpga/src/base/openfpga_title.h b/openfpga/src/base/openfpga_title.h index b4826964a..8f4ab1e90 100644 --- a/openfpga/src/base/openfpga_title.h +++ b/openfpga/src/base/openfpga_title.h @@ -9,6 +9,6 @@ /******************************************************************** * Function declaration *******************************************************************/ -const char* create_openfpga_title(); +std::string create_openfpga_title(); #endif diff --git a/openfpga/src/main.cpp b/openfpga/src/main.cpp index eb88c2c65..e1f813e9b 100644 --- a/openfpga/src/main.cpp +++ b/openfpga/src/main.cpp @@ -48,7 +48,7 @@ int main(int argc, char** argv) { */ openfpga::Shell shell("OpenFPGA"); - shell.add_title(create_openfpga_title()); + shell.add_title(create_openfpga_title().c_str()); /* Add vpr commands */ openfpga::add_vpr_commands(shell);