From 8be0829b9b85030de3b2160c67189f84de47a04d Mon Sep 17 00:00:00 2001 From: rlar Date: Thu, 16 Apr 2015 19:58:58 +0200 Subject: [PATCH] frontend/breakp.c, bug fix, "#306 Deleting breakpoint causes Internal Error in status" The "delete" command destroyed the whole list of stored breakpoints instead of just the specified one. Thanks to "jpcgt", who reported this in "#306 Deleting breakpoint causes Internal Error in status" http://sourceforge.net/p/ngspice/bugs/306/ --- src/frontend/breakp.c | 28 ++++++++++++++++------------ src/include/ngspice/fteext.h | 1 + 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/frontend/breakp.c b/src/frontend/breakp.c index fd9b6e7b6..d9c6b49af 100644 --- a/src/frontend/breakp.c +++ b/src/frontend/breakp.c @@ -296,6 +296,19 @@ com_sttus(wordlist *wl) * function settrace() in breakp2.c */ +void +dbfree1(struct dbcomm *dd) +{ + tfree(dd->db_nodename1); + tfree(dd->db_nodename2); + if (dd->db_also) { + dbfree(dd->db_also); + dd->db_also = NULL; + } + tfree(dd); +} + + void dbfree(struct dbcomm *db) { @@ -303,13 +316,7 @@ dbfree(struct dbcomm *db) for (dd = db; dd; dd = dn) { dn = dd->db_next; - tfree(dd->db_nodename1); - tfree(dd->db_nodename2); - if (dd->db_also) { - dbfree(dd->db_also); - dd->db_also = NULL; - } - tfree(dd); + dbfree1(dd); } } @@ -324,10 +331,7 @@ com_delete(wordlist *wl) struct dbcomm *d, *dt; if (wl && eq(wl->wl_word, "all")) { - for (dt = dbs; dt; dt = d) { - d = dt->db_next; - dbfree(dt); - } + dbfree(dbs); ft_curckt->ci_dbs = dbs = NULL; return; } else if (!wl) { @@ -362,7 +366,7 @@ com_delete(wordlist *wl) dt->db_next = d->db_next; else ft_curckt->ci_dbs = dbs = d->db_next; - dbfree(d); + dbfree1(d); (void) sprintf(buf, "%d", i); cp_remkword(CT_DBNUMS, buf); break; diff --git a/src/include/ngspice/fteext.h b/src/include/ngspice/fteext.h index f936b5ace..85fc2bd18 100644 --- a/src/include/ngspice/fteext.h +++ b/src/include/ngspice/fteext.h @@ -30,6 +30,7 @@ extern void ft_checkkids(void); extern bool ft_bpcheck(struct plot *runplot, int iteration); extern void dbfree(struct dbcomm *db); +extern void dbfree1(struct dbcomm *db); /* breakp2.c */