Skip to content

Commit 006cf93

Browse files
authored
🐛 Fix debugger options (#223)
1 parent 48e0915 commit 006cf93

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

platforms/CLI-Emulator/main.cpp

+7-10
Original file line numberDiff line numberDiff line change
@@ -146,19 +146,18 @@ WARDuino *wac = WARDuino::instance();
146146
Module *m;
147147

148148
struct debugger_options {
149-
const char *socket;
149+
int socket;
150150
bool no_socket;
151151
};
152152

153-
void *setupDebuggerCommunication(debugger_options *options) {
153+
void setupDebuggerCommunication(debugger_options &options) {
154154
dbg_info("\n=== STARTED DEBUGGER (in separate thread) ===\n");
155155
// Start debugger
156156
Channel *duplex;
157-
if (options->no_socket) {
157+
if (options.no_socket) {
158158
duplex = new Duplex(stdin, stdout);
159159
} else {
160-
int port = std::stoi(options->socket);
161-
duplex = new WebSocket(port);
160+
duplex = new WebSocket(options.socket);
162161
}
163162

164163
wac->debugger->setChannel(duplex);
@@ -391,12 +390,10 @@ int main(int argc, const char *argv[]) {
391390
// Start debugger (new thread)
392391
std::thread communication;
393392
if (!no_debug) {
394-
auto *options =
395-
(debugger_options *)malloc(sizeof(struct debugger_options));
396-
options->no_socket = no_socket;
397-
options->socket = socket;
393+
debugger_options options = debugger_options();
394+
options.no_socket = no_socket;
395+
options.socket = std::stoi(socket);
398396
setupDebuggerCommunication(options);
399-
free(options);
400397

401398
communication = std::thread(startDebuggerCommunication);
402399
}

0 commit comments

Comments
 (0)