From 33bb874678e5e55cbfbd2ce01a9f3a259cda1c1e Mon Sep 17 00:00:00 2001 From: Jim Monte Date: Wed, 29 Jan 2020 21:06:22 -0500 Subject: [PATCH] Add const to some parameters, made function static --- src/frontend/arg.c | 29 +++++++++++++++-------------- src/frontend/arg.h | 15 +++++++-------- src/frontend/com_measure2.c | 8 ++++++-- src/frontend/plotting/agraf.c | 8 ++++---- src/frontend/trannoise/1-f-code.c | 8 ++++---- src/spicelib/analysis/acan.c | 2 +- src/spicelib/devices/asrc/asrcext.h | 2 +- src/spicelib/devices/asrc/asrcset.c | 4 ++-- 8 files changed, 40 insertions(+), 36 deletions(-) diff --git a/src/frontend/arg.c b/src/frontend/arg.c index deeb90a93..6a09b1c86 100644 --- a/src/frontend/arg.c +++ b/src/frontend/arg.c @@ -17,7 +17,9 @@ Author: 1987 Jeffrey M. Hsu #include "variable.h" -static void common(char *string, struct wordlist *wl, struct comm *command); +static void common(const char *string, const struct wordlist *wl, + const struct comm *command); +static int countargs(const wordlist *wl); /* returns a private copy of the string */ @@ -39,11 +41,10 @@ prompt(FILE *fp) } -int -countargs(wordlist *wl) +static int countargs(const wordlist *wl) { int number = 0; - wordlist *w; + const wordlist *w; for (w = wl; w; w = w->wl_next) number++; @@ -63,42 +64,42 @@ process(wordlist *wlist) void -arg_print(wordlist *wl, struct comm *command) +arg_print(const wordlist *wl, const struct comm *command) { common("which variable", wl, command); } void -arg_plot(wordlist *wl, struct comm *command) +arg_plot(const wordlist *wl, const struct comm *command) { common("which variable", wl, command); } void -arg_load(wordlist *wl, struct comm *command) +arg_load(wordlist *wl, const struct comm *command) { /* just call com_load */ command->co_func(wl); } -void arg_let(wordlist *wl, struct comm *command) +void arg_let(const wordlist *wl, const struct comm *command) { common("which vector", wl, command); } void -arg_set(wordlist *wl, struct comm *command) +arg_set(const wordlist *wl, const struct comm *command) { common("which variable", wl, command); } void -arg_display(wordlist *wl, struct comm *command) +arg_display(const wordlist *wl, const struct comm *command) { NG_IGNORE(wl); NG_IGNORE(command); @@ -108,8 +109,8 @@ arg_display(wordlist *wl, struct comm *command) /* a common prompt routine */ -static void -common(char *string, struct wordlist *wl, struct comm *command) +static void common(const char *string, const struct wordlist *wl, + const struct comm *command) { struct wordlist *w; char *buf; @@ -125,11 +126,11 @@ common(char *string, struct wordlist *wl, struct comm *command) /* O.K. now call fn */ command->co_func(w); } -} +} /* end of function common */ void -outmenuprompt(char *string) +outmenuprompt(const char *string) { fprintf(cp_out, "%s: ", string); fflush(cp_out); diff --git a/src/frontend/arg.h b/src/frontend/arg.h index 268594532..de9ec6f09 100644 --- a/src/frontend/arg.h +++ b/src/frontend/arg.h @@ -7,15 +7,14 @@ #define ngspice_ARG_H char *prompt(FILE *fp); -int countargs(wordlist *wl); wordlist *process(wordlist *wlist); -void arg_print(wordlist *wl, struct comm *command); -void arg_plot(wordlist *wl, struct comm *command); -void arg_load(wordlist *wl, struct comm *command); -void arg_let(wordlist *wl, struct comm *command); -void arg_set(wordlist *wl, struct comm *command); -void arg_display(wordlist *wl, struct comm *command); -void outmenuprompt(char *string); +void arg_print(const wordlist *wl, const struct comm *command); +void arg_plot(const wordlist *wl, const struct comm *command); +void arg_load(wordlist *wl, const struct comm *command); +void arg_let(const wordlist *wl, const struct comm *command); +void arg_set(const wordlist *wl, const struct comm *command); +void arg_display(const wordlist *wl, const struct comm *command); +void outmenuprompt(const char *string); #endif diff --git a/src/frontend/com_measure2.c b/src/frontend/com_measure2.c index 7cc3ac0e5..83c811139 100644 --- a/src/frontend/com_measure2.c +++ b/src/frontend/com_measure2.c @@ -54,6 +54,10 @@ typedef enum AnalysisType { AT_ERR, AT_ERR1, AT_ERR2, AT_ERR3, AT_MIN_AT, AT_MAX_AT } ANALYSIS_TYPE_T; +static void measure_errMessage(const char *mName, const char *mFunction, + const char *trigTarg, const char *errMsg, int chk_only); + + /** return precision (either 5 or value of environment variable NGSPICE_MEAS_PRECISION) */ int @@ -69,8 +73,8 @@ measure_get_precision(void) } -static void -measure_errMessage(char *mName, char *mFunction, char *trigTarg, char *errMsg, int chk_only) +static void measure_errMessage(const char *mName, const char *mFunction, + const char *trigTarg, const char *errMsg, int chk_only) { if (!chk_only) { printf("\nError: measure %s %s(%s) : ", mName, mFunction, trigTarg); diff --git a/src/frontend/plotting/agraf.c b/src/frontend/plotting/agraf.c index 5acf73ea7..de750a973 100644 --- a/src/frontend/plotting/agraf.c +++ b/src/frontend/plotting/agraf.c @@ -328,9 +328,9 @@ ft_agraf(double *xlims, double *ylims, struct dvec *xscale, struct plot *plot, s out_printf("%s\n%s\n", line1, line2); - tfree(field); - tfree(line1); - tfree(line2); + txfree(field); + txfree(line1); + txfree(line2); if (!novalue) - tfree(values); + txfree(values); } diff --git a/src/frontend/trannoise/1-f-code.c b/src/frontend/trannoise/1-f-code.c index 9b55dc671..bdbcb2ef3 100644 --- a/src/frontend/trannoise/1-f-code.c +++ b/src/frontend/trannoise/1-f-code.c @@ -104,8 +104,8 @@ f_alpha(int n_pts, int n_exp, double X[], double Q_d, double alpha) #endif - tfree(hfa); - tfree(wfa); + txfree(hfa); + txfree(wfa); /* fft tables will be freed in vsrcaccept.c and isrcaccept.c fftFree(); */ fprintf(stdout, "%d 1/f noise values in time domain created\n", n_pts); @@ -247,6 +247,6 @@ trnoise_state_free(struct trnoise_state *this) { if (!this) return; - tfree(this->oneof); - tfree(this); + txfree(this->oneof); + txfree(this); } diff --git a/src/spicelib/analysis/acan.c b/src/spicelib/analysis/acan.c index 1bef51747..da8d5bd39 100644 --- a/src/spicelib/analysis/acan.c +++ b/src/spicelib/analysis/acan.c @@ -165,7 +165,7 @@ ACan(CKTcircuit *ckt, int restart) NULL, IF_REAL, numNames, nameList, IF_REAL, &acPlot); - tfree(nameList); + txfree(nameList); ipc_send_dcop_prefix(); CKTdump(ckt, 0.0, acPlot); diff --git a/src/spicelib/devices/asrc/asrcext.h b/src/spicelib/devices/asrc/asrcext.h index 70e430b4c..05d42cca5 100644 --- a/src/spicelib/devices/asrc/asrcext.h +++ b/src/spicelib/devices/asrc/asrcext.h @@ -12,6 +12,6 @@ extern int ASRCload(GENmodel *, CKTcircuit *); extern int ASRCparam(int, IFvalue *, GENinstance *, IFvalue *); extern int ASRCpzLoad(GENmodel *, CKTcircuit *, SPcomplex *); extern int ASRCacLoad(GENmodel *, CKTcircuit *); -extern int ASRCsetup(SMPmatrix *, GENmodel *, CKTcircuit *, int *); +extern int ASRCsetup(SMPmatrix *, GENmodel *, CKTcircuit *, const int *); extern int ASRCunsetup(GENmodel *, CKTcircuit *); extern int ASRCtemp(GENmodel *, CKTcircuit *); diff --git a/src/spicelib/devices/asrc/asrcset.c b/src/spicelib/devices/asrc/asrcset.c index f97ff035c..63c67d046 100644 --- a/src/spicelib/devices/asrc/asrcset.c +++ b/src/spicelib/devices/asrc/asrcset.c @@ -21,8 +21,8 @@ Author: 1987 Kanwar Jit Singh * pointers needed later for fast matrix loading */ -int -ASRCsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states) +int ASRCsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, + const int *states) { ASRCinstance *here; ASRCmodel *model = (ASRCmodel*) inModel;