From f07986d7ab356c37e54086aa0b4a2a97a7f821a7 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Wed, 4 Dec 2019 02:18:31 +0100 Subject: No more leaks --- src/main.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 80fe04e..590f2d8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -8,7 +8,7 @@ using namespace this_thread; using namespace chrono; int main(int argc, const char *argv[]) { - string msg; + string* msg; string acstat; string batlvl; string arg_one; @@ -30,12 +30,13 @@ int main(int argc, const char *argv[]) { if (strcmp(arg_one.c_str(), "--silent")) { if (argc > 2 && !strcmp(arg_one.c_str(), "--say")) { arg_two = argv[2]; - msg = arg_two; + msg = new string(arg_two); } else { - msg = "beep beep - low battery"; + msg = new string("beep beep - low battery"); } - jo_speak(msg); + jo_speak(*msg); + delete msg; } sleep_for(seconds(20)); acstat.clear(); -- cgit v1.2.3