Add const to some parameters, made function static

This commit is contained in:
Jim Monte 2020-01-29 21:06:22 -05:00 committed by Holger Vogt
parent aee256e211
commit 33bb874678
8 changed files with 40 additions and 36 deletions

View File

@ -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);

View File

@ -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

View File

@ -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);

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);

View File

@ -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 *);

View File

@ -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;