From f1a3d943bd59f9d224789eb52fec3093b417e8ad Mon Sep 17 00:00:00 2001 From: tolauwae Date: Sat, 10 Feb 2024 16:39:04 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20debugger=20options?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- platforms/CLI-Emulator/main.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/platforms/CLI-Emulator/main.cpp b/platforms/CLI-Emulator/main.cpp index df8dfbde..71111f9b 100644 --- a/platforms/CLI-Emulator/main.cpp +++ b/platforms/CLI-Emulator/main.cpp @@ -146,19 +146,18 @@ WARDuino *wac = WARDuino::instance(); Module *m; struct debugger_options { - const char *socket; + int socket; bool no_socket; }; -void *setupDebuggerCommunication(debugger_options *options) { +void setupDebuggerCommunication(debugger_options &options) { dbg_info("\n=== STARTED DEBUGGER (in separate thread) ===\n"); // Start debugger Channel *duplex; - if (options->no_socket) { + if (options.no_socket) { duplex = new Duplex(stdin, stdout); } else { - int port = std::stoi(options->socket); - duplex = new WebSocket(port); + duplex = new WebSocket(options.socket); } wac->debugger->setChannel(duplex); @@ -391,12 +390,10 @@ int main(int argc, const char *argv[]) { // Start debugger (new thread) std::thread communication; if (!no_debug) { - auto *options = - (debugger_options *)malloc(sizeof(struct debugger_options)); - options->no_socket = no_socket; - options->socket = socket; + debugger_options options = debugger_options(); + options.no_socket = no_socket; + options.socket = std::stoi(socket); setupDebuggerCommunication(options); - free(options); communication = std::thread(startDebuggerCommunication); }