From a16123997b77a5d3a137fcd80e6bf4134b7a4a23 Mon Sep 17 00:00:00 2001 From: Gareth McMullin Date: Sun, 24 Jun 2012 16:53:13 +1200 Subject: Added target.c for common target routines. --- src/target.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/target.c (limited to 'src/target.c') diff --git a/src/target.c b/src/target.c new file mode 100644 index 0000000..1c70340 --- /dev/null +++ b/src/target.c @@ -0,0 +1,48 @@ +/* + * This file is part of the Black Magic Debug project. + * + * Copyright (C) 2012 Black Sphere Technologies Ltd. + * Written by Gareth McMullin + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "general.h" +#include "target.h" + +#include + +target *target_list = NULL; +target *cur_target = NULL; +target *last_target = NULL; + +target *target_new(unsigned size) +{ + target *t = (void*)calloc(1, size); + t->next = target_list; + target_list = t; + + return t; +} + +void target_list_free(void) +{ + while(target_list) { + target *t = target_list->next; + free(target_list); + target_list = t; + } + last_target = cur_target = NULL; +} + -- cgit v1.2.3