Commit 9e866d34 authored by Masahiro Yamada's avatar Masahiro Yamada
Browse files

fiptool: refactor remove_image()



We need not handle the image_head as a special case.  Just use
a double-pointer to simplify the traverse.
Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
parent e9e0d287
...@@ -276,20 +276,20 @@ static void free_image(image_t *image) ...@@ -276,20 +276,20 @@ static void free_image(image_t *image)
static void remove_image(image_t *image) static void remove_image(image_t *image)
{ {
image_t *tmp = image_head, *prev; image_t *tmp, **p = &image_head;
if (tmp == image) { while (*p) {
image_head = tmp->next; if (*p == image)
free_image(tmp); break;
} else { p = &(*p)->next;
while (tmp != NULL && tmp != image) {
prev = tmp;
tmp = tmp->next;
}
assert(tmp != NULL);
prev->next = tmp->next;
free_image(tmp);
} }
assert(*p != NULL);
tmp = *p;
*p = tmp->next;
free_image(tmp);
nr_images--; nr_images--;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment