aboutsummaryrefslogtreecommitdiff
path: root/src/target.c
diff options
context:
space:
mode:
authorGareth McMullin2012-06-27 21:26:08 +1200
committerGareth McMullin2012-06-27 21:26:08 +1200
commit466bb66424a8a44581ae2f9defbe95aa5384c395 (patch)
treeac1ef277e96e3522907596182ce701ca0bd3468b /src/target.c
parent4581da20342c459855a4b585e72746df56e22e26 (diff)
Made cur_target, last_target static in gdb_main.c.
Added target destroy notify mechanism.
Diffstat (limited to 'src/target.c')
-rw-r--r--src/target.c17
1 files changed, 14 insertions, 3 deletions
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 <stdlib.h>
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;
+}
+