target/cortex_m: do not leak memory on reexamination

This bug was exposed by Valgrind.

Change-Id: If50878664d928c0a44e309ca1452089c1ac71466
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2542
Tested-by: jenkins
Reviewed-by: Stian Skjelstad <stian@nixia.no>
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
This commit is contained in:
Paul Fertser
2015-02-11 11:02:34 +03:00
parent b71ae9b1a7
commit 11b6ab90fb
3 changed files with 33 additions and 0 deletions

View File

@@ -72,6 +72,14 @@ struct reg_cache **register_get_last_cache_p(struct reg_cache **first)
return cache_p;
}
void register_unlink_cache(struct reg_cache **cache_p, const struct reg_cache *cache)
{
while (*cache_p && *cache_p != cache)
cache_p = &((*cache_p)->next);
if (*cache_p)
*cache_p = cache->next;
}
/** Marks the contents of the register cache as invalid (and clean). */
void register_cache_invalidate(struct reg_cache *cache)
{