From b4c6a7d32420f3849d38073f1a4ceb9583a44318 Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Thu, 23 Aug 2018 10:12:24 +0200 Subject: [PATCH] add function trnoise_state_free and use it instead of its individual components --- src/frontend/trannoise/1-f-code.c | 9 +++++++++ src/spicelib/devices/vsrc/vsrcdel.c | 5 +---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/frontend/trannoise/1-f-code.c b/src/frontend/trannoise/1-f-code.c index 4af666ee5..9b55dc671 100644 --- a/src/frontend/trannoise/1-f-code.c +++ b/src/frontend/trannoise/1-f-code.c @@ -241,3 +241,12 @@ trrandom_state_init(int rndtype, double TS, double TD, double PARAM1, double PAR return this; } + +void +trnoise_state_free(struct trnoise_state *this) +{ + if (!this) + return; + tfree(this->oneof); + tfree(this); +} diff --git a/src/spicelib/devices/vsrc/vsrcdel.c b/src/spicelib/devices/vsrc/vsrcdel.c index f6f658f68..3adb81709 100644 --- a/src/spicelib/devices/vsrc/vsrcdel.c +++ b/src/spicelib/devices/vsrc/vsrcdel.c @@ -16,10 +16,7 @@ VSRCdelete(GENinstance *gen_inst) VSRCinstance *inst = (VSRCinstance *) gen_inst; FREE(inst->VSRCcoeffs); - if (inst->VSRCtrnoise_state) { - FREE(inst->VSRCtrnoise_state->oneof); - FREE(inst->VSRCtrnoise_state); - } + trnoise_state_free(inst->VSRCtrnoise_state); FREE(inst->VSRCtrrandom_state); return OK;