From 03fdd23e9cd72c4793fc9107da8b0a08a5793a4f Mon Sep 17 00:00:00 2001 From: Gareth McMullin Date: Sun, 24 Jun 2012 21:37:10 +1200 Subject: Added mechanism for target driver to add new monitor commands. --- src/target.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/target.c') diff --git a/src/target.c b/src/target.c index 1c70340..4f2917f 100644 --- a/src/target.c +++ b/src/target.c @@ -38,11 +38,32 @@ target *target_new(unsigned size) void target_list_free(void) { + struct target_command_s *tc; + while(target_list) { target *t = target_list->next; + while (target_list->commands) { + tc = target_list->commands->next; + free(target_list->commands); + target_list->commands = tc; + } 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) +{ + struct target_command_s *tc; + if (t->commands) { + for (tc = t->commands; tc->next; tc = tc->next); + tc = tc->next = malloc(sizeof(*tc)); + } else { + t->commands = tc = malloc(sizeof(*tc)); + } + tc->specific_name = name; + tc->cmds = cmds; + tc->next = NULL; +} + -- cgit v1.2.3