forked from auracaster/openocd
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 <fercerpav@gmail.com> Reviewed-on: http://openocd.zylin.com/2544 Tested-by: jenkins Reviewed-by: Stian Skjelstad <stian@nixia.no>
This commit is contained in:
@@ -1800,6 +1800,31 @@ int target_free_working_area(struct target *target, struct working_area *area)
|
||||
return target_free_working_area_restore(target, area, 1);
|
||||
}
|
||||
|
||||
void target_quit(void)
|
||||
{
|
||||
struct target_event_callback *pe = target_event_callbacks;
|
||||
while (pe) {
|
||||
struct target_event_callback *t = pe->next;
|
||||
free(pe);
|
||||
pe = t;
|
||||
}
|
||||
target_event_callbacks = NULL;
|
||||
|
||||
struct target_timer_callback *pt = target_timer_callbacks;
|
||||
while (pt) {
|
||||
struct target_timer_callback *t = pt->next;
|
||||
free(pt);
|
||||
pt = t;
|
||||
}
|
||||
target_timer_callbacks = NULL;
|
||||
|
||||
for (struct target *target = all_targets;
|
||||
target; target = target->next) {
|
||||
if (target->type->deinit_target)
|
||||
target->type->deinit_target(target);
|
||||
}
|
||||
}
|
||||
|
||||
/* free resources and restore memory, if restoring memory fails,
|
||||
* free up resources anyway
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user