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
This commit is contained in:
parent
ae5b30ae96
commit
33a3355304
|
@ -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 */
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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 */
|
||||
|
|
Loading…
Reference in New Issue