From ea1a89b19c8ae82cbd749ca5508cffb483c1f335 Mon Sep 17 00:00:00 2001 From: "Darryl L. Miles" Date: Wed, 26 Feb 2025 13:21:46 +0000 Subject: [PATCH] EFbuild.c: efConnectionFreeLinkedList() remove delay-by-one assumption freeMagic1 series 2nd order find --- extflat/EFbuild.c | 28 ++++++++++++++++++++++++++++ extflat/EFdef.c | 9 +++------ extflat/EFint.h | 1 + 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/extflat/EFbuild.c b/extflat/EFbuild.c index 77888a20..395e86f6 100644 --- a/extflat/EFbuild.c +++ b/extflat/EFbuild.c @@ -1484,6 +1484,34 @@ efBuildUse(def, subDefName, subUseId, ta, tb, tc, td, te, tf) HashSetValue(he, (ClientData)newuse); } +/* + * ---------------------------------------------------------------------------- + * + * efConnectionFreeLinkedList -- + * + * Release memory for linked-list of Connection* based on internal list + * at Connection->conn_next. 'conn' argument must be non-NULL. + * + * Results: + * Deallocates linked-list of Connection* starting at 'conn' + * + * Side effects: + * Deallocates one or more connection record(s). + * + * ---------------------------------------------------------------------------- + */ + +void +efConnectionFreeLinkedList(Connection *conn) +{ + while (conn) + { + Connection *next = conn->conn_next; + efFreeConn(conn); + conn = next; + } +} + /* * ---------------------------------------------------------------------------- * diff --git a/extflat/EFdef.c b/extflat/EFdef.c index ef9be0fb..291c8315 100644 --- a/extflat/EFdef.c +++ b/extflat/EFdef.c @@ -119,12 +119,9 @@ EFDone(func) HashKill(&def->def_dists); HashKill(&def->def_uses); HashKill(&def->def_devs); - for (conn = def->def_conns; conn; conn = conn->conn_next) - efFreeConn(conn); - for (conn = def->def_caps; conn; conn = conn->conn_next) - efFreeConn(conn); - for (conn = def->def_resistors; conn; conn = conn->conn_next) - efFreeConn(conn); + efConnectionFreeLinkedList(def->def_conns); + efConnectionFreeLinkedList(def->def_caps); + efConnectionFreeLinkedList(def->def_resistors); free_magic1_t mm1 = freeMagic1_init(); for (kill = def->def_kills; kill; kill = kill->kill_next) diff --git a/extflat/EFint.h b/extflat/EFint.h index a4266a59..92653734 100644 --- a/extflat/EFint.h +++ b/extflat/EFint.h @@ -306,6 +306,7 @@ extern void CapHashSetValue(); extern DevParam *efGetDeviceParams(); extern void efBuildNode(); +extern void efConnectionFreeLinkedList(Connection *conn); extern void efBuildConnect(); extern void efBuildResistor(); extern void efBuildCap();