diff options
author | Tomas Vanek <vanekt@fbl.cz> | 2018-02-15 00:22:42 +0100 |
---|---|---|
committer | Tomas Vanek <vanekt@fbl.cz> | 2018-03-15 17:08:53 +0000 |
commit | 33a33553046bc720800f410adbc81bc2fb175e74 (patch) | |
tree | ab8c95bd426f3b8cb621432e160276e22ffdae41 | |
parent | ae5b30ae960b35187751e9d837d5dc42745d2376 (diff) | |
download | riscv-openocd-33a33553046bc720800f410adbc81bc2fb175e74.zip riscv-openocd-33a33553046bc720800f410adbc81bc2fb175e74.tar.gz riscv-openocd-33a33553046bc720800f410adbc81bc2fb175e74.tar.bz2 |
server: free strduped port numbers
Although the leak is negligible, the clean heap on exit will ease
valgrind testing.
Change-Id: I3a7a9c8e8dc7557aa51d0b9caa244537e5e7007d
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/4410
Tested-by: jenkins
-rw-r--r-- | src/openocd.c | 3 | ||||
-rw-r--r-- | src/server/gdb_server.c | 6 | ||||
-rw-r--r-- | src/server/gdb_server.h | 1 | ||||
-rw-r--r-- | src/server/server.c | 7 | ||||
-rw-r--r-- | src/server/server.h | 1 | ||||
-rw-r--r-- | src/server/tcl_server.c | 5 | ||||
-rw-r--r-- | src/server/tcl_server.h | 1 | ||||
-rw-r--r-- | src/server/telnet_server.c | 5 | ||||
-rw-r--r-- | src/server/telnet_server.h | 1 | ||||
-rw-r--r-- | src/target/openrisc/jsp_server.c | 4 | ||||
-rw-r--r-- | src/target/openrisc/jsp_server.h | 1 |
11 files changed, 35 insertions, 0 deletions
diff --git a/src/openocd.c b/src/openocd.c index 7394421..54fc83a 100644 --- a/src/openocd.c +++ b/src/openocd.c @@ -345,6 +345,9 @@ int openocd_main(int argc, char *argv[]) /* Start the executable meat that can evolve into thread in future. */ ret = openocd_thread(argc, argv, cmd_ctx); + gdb_service_free(); + server_free(); + unregister_all_commands(cmd_ctx, NULL); /* Shutdown commandline interface */ diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c index 5319106..c521769 100644 --- a/src/server/gdb_server.c +++ b/src/server/gdb_server.c @@ -3572,3 +3572,9 @@ int gdb_register_commands(struct command_context *cmd_ctx) gdb_port_next = strdup("3333"); return register_commands(cmd_ctx, NULL, gdb_command_handlers); } + +void gdb_service_free(void) +{ + free(gdb_port); + free(gdb_port_next); +} diff --git a/src/server/gdb_server.h b/src/server/gdb_server.h index 2b4ac4e..993984b 100644 --- a/src/server/gdb_server.h +++ b/src/server/gdb_server.h @@ -36,6 +36,7 @@ struct reg; int gdb_target_add_all(struct target *target); int gdb_register_commands(struct command_context *command_context); +void gdb_service_free(void); int gdb_put_packet(struct connection *connection, char *buffer, int len); diff --git a/src/server/server.c b/src/server/server.c index 6fa864b..8fd2d71 100644 --- a/src/server/server.c +++ b/src/server/server.c @@ -641,6 +641,13 @@ int server_quit(void) return last_signal; } +void server_free(void) +{ + tcl_service_free(); + telnet_service_free(); + jsp_service_free(); +} + void exit_on_signal(int sig) { #ifndef _WIN32 diff --git a/src/server/server.h b/src/server/server.h index 8c80626..d4eae94 100644 --- a/src/server/server.h +++ b/src/server/server.h @@ -82,6 +82,7 @@ int add_service(char *name, const char *port, int server_preinit(void); int server_init(struct command_context *cmd_ctx); int server_quit(void); +void server_free(void); void exit_on_signal(int); int server_loop(struct command_context *command_context); diff --git a/src/server/tcl_server.c b/src/server/tcl_server.c index 7c40f7d..3cb63a2 100644 --- a/src/server/tcl_server.c +++ b/src/server/tcl_server.c @@ -359,3 +359,8 @@ int tcl_register_commands(struct command_context *cmd_ctx) tcl_port = strdup("6666"); return register_commands(cmd_ctx, NULL, tcl_command_handlers); } + +void tcl_service_free(void) +{ + free(tcl_port); +} diff --git a/src/server/tcl_server.h b/src/server/tcl_server.h index 422c794..6ce3ab9 100644 --- a/src/server/tcl_server.h +++ b/src/server/tcl_server.h @@ -22,5 +22,6 @@ int tcl_init(void); int tcl_register_commands(struct command_context *cmd_ctx); +void tcl_service_free(void); #endif /* OPENOCD_SERVER_TCL_SERVER_H */ diff --git a/src/server/telnet_server.c b/src/server/telnet_server.c index 9077b6c..a864f5f 100644 --- a/src/server/telnet_server.c +++ b/src/server/telnet_server.c @@ -719,3 +719,8 @@ int telnet_register_commands(struct command_context *cmd_ctx) telnet_port = strdup("4444"); return register_commands(cmd_ctx, NULL, telnet_command_handlers); } + +void telnet_service_free(void) +{ + free(telnet_port); +} diff --git a/src/server/telnet_server.h b/src/server/telnet_server.h index 5e238f4..27148d7 100644 --- a/src/server/telnet_server.h +++ b/src/server/telnet_server.h @@ -64,5 +64,6 @@ struct telnet_service { int telnet_init(char *banner); int telnet_register_commands(struct command_context *command_context); +void telnet_service_free(void); #endif /* OPENOCD_SERVER_TELNET_SERVER_H */ diff --git a/src/target/openrisc/jsp_server.c b/src/target/openrisc/jsp_server.c index 2d90114..6cd53f4 100644 --- a/src/target/openrisc/jsp_server.c +++ b/src/target/openrisc/jsp_server.c @@ -242,3 +242,7 @@ int jsp_register_commands(struct command_context *cmd_ctx) return register_commands(cmd_ctx, NULL, jsp_command_handlers); } +void jsp_service_free(void) +{ + free(jsp_port); +} diff --git a/src/target/openrisc/jsp_server.h b/src/target/openrisc/jsp_server.h index f8e7121..e5cfaa8 100644 --- a/src/target/openrisc/jsp_server.h +++ b/src/target/openrisc/jsp_server.h @@ -13,5 +13,6 @@ struct jsp_service { int jsp_init(struct or1k_jtag *jtag_info, char *banner); int jsp_register_commands(struct command_context *cmd_ctx); +void jsp_service_free(void); #endif /* OPENOCD_TARGET_OPENRISC_JSP_SERVER_H */ |