From d298d5cc2fb6e5e6e4089e5f4ad970751d68cea2 Mon Sep 17 00:00:00 2001 From: rlar Date: Fri, 22 Jul 2016 20:44:17 +0200 Subject: [PATCH] use memset() instead of deprecated bzero() --- configure.ac | 2 +- src/frontend/init.c | 2 +- src/frontend/outitf.c | 4 ++-- src/frontend/subckt.c | 2 +- src/include/ngspice/memory.h | 4 ++-- src/include/ngspice/stringutil.h | 4 ---- src/maths/ni/nicomcof.c | 4 ++-- src/misc/alloc.c | 2 +- src/misc/string.c | 14 -------------- src/sharedspice.c | 2 +- src/spicelib/devices/nbjt/nbjtset.c | 2 +- src/spicelib/devices/nbjt2/nbt2set.c | 2 +- src/spicelib/devices/numd/numdset.c | 2 +- src/spicelib/devices/numd2/nud2set.c | 2 +- src/spicelib/devices/numos/nummset.c | 2 +- visualc/src/include/ngspice/config.h | 3 --- 16 files changed, 16 insertions(+), 37 deletions(-) diff --git a/configure.ac b/configure.ac index 4b46af9f2..40dfcf25a 100644 --- a/configure.ac +++ b/configure.ac @@ -712,7 +712,7 @@ AC_CHECK_FUNCS([isatty tcgetattr tcsetattr]) # Check for a few functions: AC_FUNC_FORK([]) -AC_CHECK_FUNCS([access bzero qsort dup2 popen]) +AC_CHECK_FUNCS([access qsort dup2 popen]) AC_CHECK_FUNCS([strchr index], [break]) AC_CHECK_FUNCS([strrchr rindex], [break]) AC_CHECK_FUNCS([getcwd getwd], [break]) diff --git a/src/frontend/init.c b/src/frontend/init.c index 7b26f273f..fddb48679 100644 --- a/src/frontend/init.c +++ b/src/frontend/init.c @@ -27,7 +27,7 @@ cp_init(void) { char *s; - bzero(cp_chars, 128); + memset(cp_chars, 0, 128); for (s = singlec; *s; s++) /* break word to right or left of characters <>;&*/ cp_chars[(int) *s] = (CPC_BRR | CPC_BRL); diff --git a/src/frontend/outitf.c b/src/frontend/outitf.c index f2417cb3f..4bf273921 100644 --- a/src/frontend/outitf.c +++ b/src/frontend/outitf.c @@ -412,7 +412,7 @@ addDataDesc(runDesc *run, char *name, int type, int ind) data = &run->data[run->numData]; /* so freeRun will get nice NULL pointers for the fields we don't set */ - bzero(data, sizeof(dataDesc)); + memset(data, 0, sizeof(dataDesc)); data->name = copy(name); data->type = type; @@ -443,7 +443,7 @@ addSpecialDesc(runDesc *run, char *name, char *devname, char *param, int depind) data = &run->data[run->numData]; /* so freeRun will get nice NULL pointers for the fields we don't set */ - bzero(data, sizeof(dataDesc)); + memset(data, 0, sizeof(dataDesc)); data->name = copy(name); diff --git a/src/frontend/subckt.c b/src/frontend/subckt.c index 9d03a83f8..89ea8bbdf 100644 --- a/src/frontend/subckt.c +++ b/src/frontend/subckt.c @@ -1391,7 +1391,7 @@ settrans(char *formal, char *actual, const char *subname) { int i; - bzero(table, sizeof(*table)); + memset(table, 0, sizeof(*table)); for (i = 0; ; i++) { table[i].t_old = gettok(&formal); diff --git a/src/include/ngspice/memory.h b/src/include/ngspice/memory.h index ef259e185..75a64b188 100644 --- a/src/include/ngspice/memory.h +++ b/src/include/ngspice/memory.h @@ -27,10 +27,10 @@ extern void txfree(const void *ptr); #endif /* HAVE_LIBGC */ -#include "ngspice/stringutil.h" /* va: spice3 internally bzero */ +#include "ngspice/stringutil.h" #define FREE(x) do { if(x) { txfree(x); (x) = NULL; } } while(0) -#define ZERO(PTR, TYPE) bzero(PTR, sizeof(TYPE)) +#define ZERO(PTR, TYPE) memset(PTR, 0, sizeof(TYPE)) #ifdef CIDER diff --git a/src/include/ngspice/stringutil.h b/src/include/ngspice/stringutil.h index 9c32afcf3..e8faf1aa8 100644 --- a/src/include/ngspice/stringutil.h +++ b/src/include/ngspice/stringutil.h @@ -44,10 +44,6 @@ int cinprefix(register char *p, register char *s, register int n); int cimatch(register char *p, register char *s); #endif -#ifndef HAVE_BZERO -void bzero(void *ptr, size_t num); -#endif - bool isquote(char ch); bool is_arith_char(char c); bool str_has_arith_char(char *s); diff --git a/src/maths/ni/nicomcof.c b/src/maths/ni/nicomcof.c index 2b9b5052c..6ac0ae9c1 100644 --- a/src/maths/ni/nicomcof.c +++ b/src/maths/ni/nicomcof.c @@ -62,7 +62,7 @@ NIcomCof(CKTcircuit *ckt) case 4: case 5: case 6: - bzero(ckt->CKTag,7*sizeof(double)); + memset(ckt->CKTag, 0, 7*sizeof(double)); ckt->CKTag[1] = -1/ckt->CKTdelta; /* first, set up the matrix */ arg=0; @@ -150,7 +150,7 @@ NIcomCof(CKTcircuit *ckt) * MUST STILL ACCOUNT FOR ARRAY AGP() * KEEP THE SAME NAME FOR GMAT */ - bzero(ckt->CKTagp,7*sizeof(double)); + memset(ckt->CKTagp, 0, 7*sizeof(double)); /* SET UP RHS OF EQUATIONS */ ckt->CKTagp[0]=1; for(i=0;i<=ckt->CKTorder;i++) { diff --git a/src/misc/alloc.c b/src/misc/alloc.c index 76d171cca..d870999e2 100644 --- a/src/misc/alloc.c +++ b/src/misc/alloc.c @@ -46,7 +46,7 @@ extern mutexType allocMutex; * be tmalloc'd. Return NULL for a request for 0 bytes. */ -/* New implementation of tmalloc, it uses calloc and does not call bzero() */ +/* New implementation of tmalloc, it uses calloc and does not call memset() */ void * tmalloc(size_t num) diff --git a/src/misc/string.c b/src/misc/string.c index ba1972268..f22ca710d 100644 --- a/src/misc/string.c +++ b/src/misc/string.c @@ -599,20 +599,6 @@ stripWhiteSpacesInsideParens(char *str) } -#ifndef HAVE_BZERO -#ifndef bzero -void -bzero(void *vptr, size_t num) -{ - register char *ptr=vptr; - while (num-- > 0) - *ptr++ = '\0'; - return; -} -#endif -#endif - - bool isquote( char ch ) { diff --git a/src/sharedspice.c b/src/sharedspice.c index 78be02a26..0e9490ea4 100644 --- a/src/sharedspice.c +++ b/src/sharedspice.c @@ -1547,7 +1547,7 @@ int sh_ExecutePerLoop_old(void) tfree(curvecvals); } len = 0; - bzero(type_name, 128); + memset(type_name, 0, 128); } /* initialize new for every new plot, e.g. if changed from op1 to ac1 diff --git a/src/spicelib/devices/nbjt/nbjtset.c b/src/spicelib/devices/nbjt/nbjtset.c index 71ea25bb9..2d723c087 100644 --- a/src/spicelib/devices/nbjt/nbjtset.c +++ b/src/spicelib/devices/nbjt/nbjtset.c @@ -211,7 +211,7 @@ NBJTsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states) ONEgetStatePointers(inst->NBJTpDevice, states); /* Wipe out statistics from previous runs (if any). */ - bzero(inst->NBJTpDevice->pStats, sizeof(ONEstats)); + memset(inst->NBJTpDevice->pStats, 0, sizeof(ONEstats)); inst->NBJTpDevice->pStats->totalTime[STAT_SETUP] += SPfrontEnd->IFseconds() - startTime; diff --git a/src/spicelib/devices/nbjt2/nbt2set.c b/src/spicelib/devices/nbjt2/nbt2set.c index e9094d7b7..c0b584da5 100644 --- a/src/spicelib/devices/nbjt2/nbt2set.c +++ b/src/spicelib/devices/nbjt2/nbt2set.c @@ -227,7 +227,7 @@ NBJT2setup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states) TWOgetStatePointers(inst->NBJT2pDevice, states); /* Wipe out statistics from previous runs (if any). */ - bzero(inst->NBJT2pDevice->pStats, sizeof(TWOstats)); + memset(inst->NBJT2pDevice->pStats, 0, sizeof(TWOstats)); inst->NBJT2pDevice->pStats->totalTime[STAT_SETUP] += SPfrontEnd->IFseconds() - startTime; diff --git a/src/spicelib/devices/numd/numdset.c b/src/spicelib/devices/numd/numdset.c index a1b4d527f..310db3045 100644 --- a/src/spicelib/devices/numd/numdset.c +++ b/src/spicelib/devices/numd/numdset.c @@ -200,7 +200,7 @@ NUMDsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states) ONEgetStatePointers(inst->NUMDpDevice, states); /* Wipe out statistics from previous runs (if any). */ - bzero(inst->NUMDpDevice->pStats, sizeof(ONEstats)); + memset(inst->NUMDpDevice->pStats, 0, sizeof(ONEstats)); inst->NUMDpDevice->pStats->totalTime[STAT_SETUP] += SPfrontEnd->IFseconds() - startTime; diff --git a/src/spicelib/devices/numd2/nud2set.c b/src/spicelib/devices/numd2/nud2set.c index 39a2b5ea2..126696d41 100644 --- a/src/spicelib/devices/numd2/nud2set.c +++ b/src/spicelib/devices/numd2/nud2set.c @@ -225,7 +225,7 @@ NUMD2setup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states) TWOgetStatePointers(inst->NUMD2pDevice, states); /* Wipe out statistics from previous runs (if any). */ - bzero(inst->NUMD2pDevice->pStats, sizeof(TWOstats)); + memset(inst->NUMD2pDevice->pStats, 0, sizeof(TWOstats)); inst->NUMD2pDevice->pStats->totalTime[STAT_SETUP] += SPfrontEnd->IFseconds() - startTime; diff --git a/src/spicelib/devices/numos/nummset.c b/src/spicelib/devices/numos/nummset.c index bfb10642a..c4c1d26c1 100644 --- a/src/spicelib/devices/numos/nummset.c +++ b/src/spicelib/devices/numos/nummset.c @@ -224,7 +224,7 @@ NUMOSsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states) TWOgetStatePointers(inst->NUMOSpDevice, states); /* Wipe out statistics from previous runs (if any). */ - bzero(inst->NUMOSpDevice->pStats, sizeof(TWOstats)); + memset(inst->NUMOSpDevice->pStats, 0, sizeof(TWOstats)); inst->NUMOSpDevice->pStats->totalTime[STAT_SETUP] += SPfrontEnd->IFseconds() - startTime; diff --git a/visualc/src/include/ngspice/config.h b/visualc/src/include/ngspice/config.h index 2eff8f659..65129bf8d 100644 --- a/visualc/src/include/ngspice/config.h +++ b/visualc/src/include/ngspice/config.h @@ -80,9 +80,6 @@ /* Define to enable BSD editline */ /* #undef HAVE_BSDEDITLINE */ -/* Define to 1 if you have the `bzero' function. */ -/* #undef HAVE_BZERO */ - /* Define to 1 if you have the header file. */ #define HAVE_CTYPE_H 1