From 2d998c09446a230b669f0ea9771dabf2dbea2fe8 Mon Sep 17 00:00:00 2001 From: Paul Fertser Date: Wed, 11 Feb 2015 11:08:40 +0300 Subject: server, target, cortex_m: add deinit_target to the API to free resources This should facilitate dynamic target creation and removal. Currently it helps with getting 0 bytes lost report from Valgrind on exit (after talking to a nucleo board). However, 1,223,886 bytes in 5,268 blocks are still reachable which means the app holds pointers to that data on exit. The majority comes from the jtag command queue, there're also many blocks from TCL command registration. Change-Id: I7523234bb90fffd26f7d29cdd7648ddd221d46ab Signed-off-by: Paul Fertser Reviewed-on: http://openocd.zylin.com/2544 Tested-by: jenkins Reviewed-by: Stian Skjelstad --- src/target/cortex_m.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/target/cortex_m.c') diff --git a/src/target/cortex_m.c b/src/target/cortex_m.c index 028bfd8..4dc92c8 100644 --- a/src/target/cortex_m.c +++ b/src/target/cortex_m.c @@ -1685,6 +1685,15 @@ static int cortex_m_init_target(struct command_context *cmd_ctx, return ERROR_OK; } +void cortex_m_deinit_target(struct target *target) +{ + struct cortex_m_common *cortex_m = target_to_cm(target); + + free(cortex_m->fp_comparator_list); + cortex_m_dwt_free(target); + free(cortex_m); +} + /* REVISIT cache valid/dirty bits are unmaintained. We could set "valid" * on r/w if the core is not running, and clear on resume or reset ... or * at least, in a post_restore_context() method. @@ -2362,4 +2371,5 @@ struct target_type cortexm_target = { .target_create = cortex_m_target_create, .init_target = cortex_m_init_target, .examine = cortex_m_examine, + .deinit_target = cortex_m_deinit_target, }; -- cgit v1.1