]> git.sur5r.net Git - openocd/commitdiff
server: free strduped port numbers
authorTomas Vanek <vanekt@fbl.cz>
Wed, 14 Feb 2018 23:22:42 +0000 (00:22 +0100)
committerTomas Vanek <vanekt@fbl.cz>
Thu, 15 Mar 2018 17:08:53 +0000 (17:08 +0000)
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
src/openocd.c
src/server/gdb_server.c
src/server/gdb_server.h
src/server/server.c
src/server/server.h
src/server/tcl_server.c
src/server/tcl_server.h
src/server/telnet_server.c
src/server/telnet_server.h
src/target/openrisc/jsp_server.c
src/target/openrisc/jsp_server.h

index 739442163cddc46e10f3450fc343ed4c28b8910d..54fc83a1729659c7d0785af0e59ca4d66f19bc6e 100644 (file)
@@ -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 */
index 5319106a33681b1dd3f4477b4fc1015fd0f45b0c..c52176911dfc2b8567bd0d018ceea5f5c3fc10d6 100644 (file)
@@ -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);
+}
index 2b4ac4eafccd5e5a9c9b22645014031265d93d50..993984bc3814e34019f1f55b315c9c805cacd6a5 100644 (file)
@@ -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);
 
index 6fa864bbc67eb8ec5222f044e20245c758d8bc4f..8fd2d71d4fc52247a3bc7a83a2a5ceb4fec62876 100644 (file)
@@ -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
index 8c80626759eb199a17aeedaf27cb7926b58061ed..d4eae942403ca7187fc910e90ae33d2380a5f983 100644 (file)
@@ -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);
index 7c40f7dce9c49908e09b234183137288f6ebc2ae..3cb63a275ce37b9f693d72fc1dd1ad7ea7b03dda 100644 (file)
@@ -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);
+}
index 422c794eec721ec700f2e98c06836bcd5d29a3ab..6ce3ab95fe42a7198db84847423f659b87b527cc 100644 (file)
@@ -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 */
index 9077b6c46d2e51b3d31f1cf0b51ff9fba38a1e7a..a864f5fd293ea5d520b42f89052c95aab60a821a 100644 (file)
@@ -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);
+}
index 5e238f441f7a2dfb687511baac2aac0b899fe010..27148d7ceeaee357c8f2af0b445206f65dc72c66 100644 (file)
@@ -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 */
index 2d90114faa799ce0503431549b0c7cf79ea2483b..6cd53f43cd17a83e049a1f4d9def6062bda41683 100644 (file)
@@ -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);
+}
index f8e71215a8eba0fea0976887aa327d2d9d82a879..e5cfaa8b4695e4b2ee6167f8da3372d3100d094e 100644 (file)
@@ -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 */