From 466bb66424a8a44581ae2f9defbe95aa5384c395 Mon Sep 17 00:00:00 2001 From: Gareth McMullin Date: Wed, 27 Jun 2012 21:26:08 +1200 Subject: Made cur_target, last_target static in gdb_main.c. Added target destroy notify mechanism. --- src/target.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src/target.c') diff --git a/src/target.c b/src/target.c index 4f2917f..5189929 100644 --- a/src/target.c +++ b/src/target.c @@ -24,8 +24,6 @@ #include target *target_list = NULL; -target *cur_target = NULL; -target *last_target = NULL; target *target_new(unsigned size) { @@ -42,6 +40,8 @@ void target_list_free(void) while(target_list) { target *t = target_list->next; + if (target_list->destroy_callback) + target_list->destroy_callback(target_list); while (target_list->commands) { tc = target_list->commands->next; free(target_list->commands); @@ -50,7 +50,6 @@ void target_list_free(void) free(target_list); target_list = t; } - last_target = cur_target = NULL; } void target_add_commands(target *t, const struct command_s *cmds, const char *name) @@ -67,3 +66,15 @@ void target_add_commands(target *t, const struct command_s *cmds, const char *na tc->next = NULL; } +target *target_attach(target *t, target_destroy_callback destroy_cb) +{ + if (t->destroy_callback) + t->destroy_callback(t); + + t->destroy_callback = destroy_cb; + + t->attach(t); + + return t; +} + -- cgit v1.2.3