From 141ed61ec833013250fb9b80a5e324abea8eeef0 Mon Sep 17 00:00:00 2001 From: rlar Date: Sat, 23 Jul 2016 09:13:55 +0200 Subject: [PATCH] use memcpy() instead of deprecated bcopy() --- configure.ac | 2 +- src/ciderlib/support/database.c | 2 +- src/frontend/com_let.c | 4 ++-- src/frontend/define.c | 8 ++++---- src/frontend/gens.c | 2 +- src/frontend/plotting/agraf.c | 2 +- src/frontend/plotting/graphdb.c | 2 +- src/frontend/plotting/plotcurv.c | 4 ++-- src/frontend/plotting/plotit.c | 4 ++-- src/frontend/postcoms.c | 4 ++-- src/frontend/variable.c | 4 ++-- src/frontend/vectors.c | 10 +++++----- src/include/ngspice/stringutil.h | 4 ---- src/maths/poly/interpolate.c | 4 ++-- src/misc/string.c | 14 -------------- src/spicelib/analysis/dcpss.c | 2 +- src/spicelib/analysis/dctran.c | 2 +- src/spicelib/analysis/dctrcurv.c | 2 +- src/spicelib/devices/nbjt/nbjtset.c | 2 +- src/spicelib/devices/nbjt/nbjttemp.c | 2 +- src/spicelib/devices/nbjt2/nbt2set.c | 2 +- src/spicelib/devices/nbjt2/nbt2temp.c | 2 +- src/spicelib/devices/numd/numdset.c | 2 +- src/spicelib/devices/numd/numdtemp.c | 2 +- src/spicelib/devices/numd2/nud2set.c | 2 +- src/spicelib/devices/numd2/nud2temp.c | 2 +- src/spicelib/devices/numos/nummset.c | 2 +- src/spicelib/devices/numos/nummtemp.c | 2 +- visualc/src/include/ngspice/config.h | 3 --- 29 files changed, 39 insertions(+), 60 deletions(-) diff --git a/configure.ac b/configure.ac index d4992dc6d..4b46af9f2 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 bcopy bzero qsort dup2 popen]) +AC_CHECK_FUNCS([access bzero 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/ciderlib/support/database.c b/src/ciderlib/support/database.c index 2dc4c55f2..5428d014e 100644 --- a/src/ciderlib/support/database.c +++ b/src/ciderlib/support/database.c @@ -38,7 +38,7 @@ DBgetData(struct plot *plot, char *name, int lengthWanted) data = TMALLOC(double, v->v_length); if (isreal(v)) { - bcopy(v->v_realdata, data, sizeof (double) * (size_t) v->v_length); + memcpy(data, v->v_realdata, sizeof (double) * (size_t) v->v_length); } else { for (i=0; i < v->v_length; i++) { data[i] = realpart(v->v_compdata[i]); diff --git a/src/frontend/com_let.c b/src/frontend/com_let.c index 41005a049..6e8b26da2 100644 --- a/src/frontend/com_let.c +++ b/src/frontend/com_let.c @@ -218,10 +218,10 @@ com_let(wordlist *wl) n->v_flags &= ~VF_PERMANENT; goto quit; } else if (isreal(t)) { - bcopy(t->v_realdata, n->v_realdata + offset, + memcpy(n->v_realdata + offset, t->v_realdata, (size_t) length * sizeof(double)); } else { - bcopy(t->v_compdata, n->v_compdata + offset, + memcpy(n->v_compdata + offset, t->v_compdata, (size_t) length * sizeof(ngcomplex_t)); } diff --git a/src/frontend/define.c b/src/frontend/define.c index c97750d18..b8523c424 100644 --- a/src/frontend/define.c +++ b/src/frontend/define.c @@ -169,12 +169,12 @@ savetree(struct pnode *pn) /* this dvec isn't member of any plot */ if (isreal(d)) { - bcopy(d->v_realdata, - pn->pn_value->v_realdata, + memcpy(pn->pn_value->v_realdata, + d->v_realdata, sizeof(double) * (size_t) d->v_length); } else { - bcopy(d->v_compdata, - pn->pn_value->v_compdata, + memcpy(pn->pn_value->v_compdata, + d->v_compdata, sizeof(ngcomplex_t) * (size_t) d->v_length); } } diff --git a/src/frontend/gens.c b/src/frontend/gens.c index 5a4a9ac0c..d9df16a3a 100644 --- a/src/frontend/gens.c +++ b/src/frontend/gens.c @@ -65,7 +65,7 @@ dgen_for_n(dgen *dg, int n, int (*fn) (dgen*, IFparm*, int), IFparm *data, int s int dnum, i, j, k; dgxp = &dgx; - bcopy(dg, dgxp, sizeof(dgx)); /* va: compatible pointer types */ + memcpy(dgxp, dg, sizeof(dgx)); /* va: compatible pointer types */ dnum = dgxp->dev_type_no; diff --git a/src/frontend/plotting/agraf.c b/src/frontend/plotting/agraf.c index f2e8a2369..435474fe5 100644 --- a/src/frontend/plotting/agraf.c +++ b/src/frontend/plotting/agraf.c @@ -178,7 +178,7 @@ ft_agraf(double *xlims, double *ylims, struct dvec *xscale, struct plot *plot, s field[k * omaxy + i] = LCHAR; line1[i + margin + 2 * shift] = '|'; (void) sprintf(buf, "%.2e", j * pow(10.0, (double) mag)); - bcopy(buf, &line2[i + margin - ((j < 0) ? 2 : 1) - shift], + memcpy(&line2[i + margin - ((j < 0) ? 2 : 1) - shift], buf, strlen(buf)); } line1[i - spacing + margin + 1] = '\0'; diff --git a/src/frontend/plotting/graphdb.c b/src/frontend/plotting/graphdb.c index 4dc741464..c4a2d70fb 100644 --- a/src/frontend/plotting/graphdb.c +++ b/src/frontend/plotting/graphdb.c @@ -110,7 +110,7 @@ CopyGraph(GRAPH *graph) struct dveclist *link, *newlink; ret = NewGraph(); - bcopy(graph, ret, sizeof(GRAPH)); /* va: compatible pointer types */ + memcpy(ret, graph, sizeof(GRAPH)); /* va: compatible pointer types */ ret->graphid = RunningId - 1; /* restore id */ diff --git a/src/frontend/plotting/plotcurv.c b/src/frontend/plotting/plotcurv.c index f04ddb65f..f8cea7b4f 100644 --- a/src/frontend/plotting/plotcurv.c +++ b/src/frontend/plotting/plotcurv.c @@ -219,13 +219,13 @@ ft_graf(struct dvec *v, struct dvec *xs, bool nostart) /* Plot the first degree segments... */ if (isreal(v)) - bcopy(v->v_realdata, ydata, (size_t)(degree + 1) * sizeof(double)); + memcpy(ydata, v->v_realdata, (size_t)(degree + 1) * sizeof(double)); else for (i = 0; i <= degree; i++) ydata[i] = realpart(v->v_compdata[i]); if (isreal(xs)) - bcopy(xs->v_realdata, xdata, (size_t)(degree + 1) * sizeof(double)); + memcpy(xdata, xs->v_realdata, (size_t)(degree + 1) * sizeof(double)); else for (i = 0; i <= degree; i++) xdata[i] = realpart(xs->v_compdata[i]); diff --git a/src/frontend/plotting/plotit.c b/src/frontend/plotting/plotit.c index b13a21219..8e9035723 100644 --- a/src/frontend/plotting/plotit.c +++ b/src/frontend/plotting/plotit.c @@ -131,11 +131,11 @@ compress(struct dvec *d, double *xcomp, double *xind) newlen = ihi - ilo; if (isreal(d)) { double *dd = TMALLOC(double, newlen); - bcopy(d->v_realdata + ilo, dd, (size_t) newlen * sizeof(double)); + memcpy(dd, d->v_realdata + ilo, (size_t) newlen * sizeof(double)); dvec_realloc(d, newlen, dd); } else { ngcomplex_t *cc = TMALLOC(ngcomplex_t, newlen); - bcopy(d->v_compdata + ilo, cc, (size_t) newlen * sizeof(ngcomplex_t)); + memcpy(cc, d->v_compdata + ilo, (size_t) newlen * sizeof(ngcomplex_t)); dvec_realloc(d, newlen, cc); } } diff --git a/src/frontend/postcoms.c b/src/frontend/postcoms.c index 4f365b80e..138d69dec 100644 --- a/src/frontend/postcoms.c +++ b/src/frontend/postcoms.c @@ -433,7 +433,7 @@ com_write(wordlist *wl) tpl = vecs->v_plot; tpl->pl_written = TRUE; end = NULL; - bcopy(tpl, &newplot, sizeof(struct plot)); + memcpy(&newplot, tpl, sizeof(struct plot)); scalefound = FALSE; /* Figure out how many vectors are in this plot. Also look @@ -599,7 +599,7 @@ com_write_sparam(wordlist *wl) tpl = vecs->v_plot; tpl->pl_written = TRUE; end = NULL; - bcopy(tpl, &newplot, sizeof(struct plot)); + memcpy(&newplot, tpl, sizeof(struct plot)); scalefound = FALSE; /* Figure out how many vectors are in this plot. Also look diff --git a/src/frontend/variable.c b/src/frontend/variable.c index 2b998d44b..ad239e1bb 100644 --- a/src/frontend/variable.c +++ b/src/frontend/variable.c @@ -220,7 +220,7 @@ cp_vset(char *varname, enum cp_types type, void *value) v->va_next = ft_curckt->ci_vars; ft_curckt->ci_vars = v; } else { - /* va: avoid memory leak within bcopy */ + /* va: avoid memory leak within memcpy */ if (u->va_type == CP_STRING) tfree(u->va_string); else if (u->va_type == CP_LIST) @@ -233,7 +233,7 @@ cp_vset(char *varname, enum cp_types type, void *value) tfree(v); /* va: old version with memory leaks w = u->va_next; - bcopy(v, u, sizeof(*u)); + memcpy(u, v, sizeof(*u)); u->va_next = w; */ } diff --git a/src/frontend/vectors.c b/src/frontend/vectors.c index c0971d50b..f06b1b362 100644 --- a/src/frontend/vectors.c +++ b/src/frontend/vectors.c @@ -687,10 +687,10 @@ vec_copy(struct dvec *v) v->v_length, NULL); if (isreal(v)) - bcopy(v->v_realdata, nv->v_realdata, + memcpy(nv->v_realdata, v->v_realdata, sizeof(double) * (size_t) v->v_length); else - bcopy(v->v_compdata, nv->v_compdata, + memcpy(nv->v_compdata, v->v_compdata, sizeof(ngcomplex_t) * (size_t) v->v_length); nv->v_minsignal = v->v_minsignal; @@ -1031,7 +1031,7 @@ vec_transpose(struct dvec *v) * newa[j,i] is at data[j*dim1+i] * where j is in [0, dim0-1] and i is in [0, dim1-1] * Since contiguous data in the old array is scattered in the new array - * we can't use bcopy :(. There is probably a BLAS2 function for this + * we can't use memcpy :(. There is probably a BLAS2 function for this * though. The formulation below gathers scattered old data into * consecutive new data. */ @@ -1113,9 +1113,9 @@ vec_mkfamily(struct dvec *v) d->v_dims[0] = size; if (isreal(v)) { - bcopy(v->v_realdata + size*i, d->v_realdata, (size_t) size * sizeof(double)); + memcpy(d->v_realdata, v->v_realdata + size*i, (size_t) size * sizeof(double)); } else { - bcopy(v->v_compdata + size*i, d->v_compdata, (size_t) size * sizeof(ngcomplex_t)); + memcpy(d->v_compdata, v->v_compdata + size*i, (size_t) size * sizeof(ngcomplex_t)); } /* Add one to the counter. */ (void) incindex(count, v->v_numdims - 1, v->v_dims, v->v_numdims); diff --git a/src/include/ngspice/stringutil.h b/src/include/ngspice/stringutil.h index f715dac5a..9c32afcf3 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_BCOPY -void bcopy(const void *from, void *to, size_t num); -#endif - #ifndef HAVE_BZERO void bzero(void *ptr, size_t num); #endif diff --git a/src/maths/poly/interpolate.c b/src/maths/poly/interpolate.c index ccd34aad3..6397f5cb7 100644 --- a/src/maths/poly/interpolate.c +++ b/src/maths/poly/interpolate.c @@ -60,8 +60,8 @@ ft_interpolate(double *data, double *ndata, double *oscale, int olen, ydata = TMALLOC(double, degree + 1); /* Deal with the first degree pieces. */ - bcopy(data, ydata, (size_t) (degree + 1) * sizeof (double)); - bcopy(oscale, xdata, (size_t) (degree + 1) * sizeof (double)); + memcpy(ydata, data, (size_t) (degree + 1) * sizeof (double)); + memcpy(xdata, oscale, (size_t) (degree + 1) * sizeof (double)); while (!ft_polyfit(xdata, ydata, result, degree, scratch)) { /* If it doesn't work this time, bump the interpolation diff --git a/src/misc/string.c b/src/misc/string.c index c95a43413..ba1972268 100644 --- a/src/misc/string.c +++ b/src/misc/string.c @@ -599,20 +599,6 @@ stripWhiteSpacesInsideParens(char *str) } -#ifndef HAVE_BCOPY -#ifndef bcopy -void -bcopy(const void *vfrom, void *vto, size_t num) -{ - register const char *from=vfrom; - register char *to=vto; - while (num-- > 0) - *to++ = *from++; - return; -} -#endif -#endif - #ifndef HAVE_BZERO #ifndef bzero void diff --git a/src/spicelib/analysis/dcpss.c b/src/spicelib/analysis/dcpss.c index 9b699deea..c012bd6e9 100644 --- a/src/spicelib/analysis/dcpss.c +++ b/src/spicelib/analysis/dcpss.c @@ -390,7 +390,7 @@ DCpss(CKTcircuit *ckt, ckt->CKTag[0]=ckt->CKTag[1]=0; /* State0 copied into State1 - DEPRECATED LEGACY function - to be replaced with memmove() */ - bcopy(ckt->CKTstate0, ckt->CKTstate1, + memcpy(ckt->CKTstate1, ckt->CKTstate0, (size_t) ckt->CKTnumStates * sizeof(double)); /* Statistics Initialization using a macro at the beginning of this code */ diff --git a/src/spicelib/analysis/dctran.c b/src/spicelib/analysis/dctran.c index e318c409f..34826d14e 100644 --- a/src/spicelib/analysis/dctran.c +++ b/src/spicelib/analysis/dctran.c @@ -341,7 +341,7 @@ DCtran(CKTcircuit *ckt, ckt->CKTmode = (ckt->CKTmode&MODEUIC) | MODETRAN | MODEINITTRAN; /* modeinittran set here */ ckt->CKTag[0]=ckt->CKTag[1]=0; - bcopy(ckt->CKTstate0, ckt->CKTstate1, + memcpy(ckt->CKTstate1, ckt->CKTstate0, (size_t) ckt->CKTnumStates * sizeof(double)); #ifdef WANT_SENSE2 diff --git a/src/spicelib/analysis/dctrcurv.c b/src/spicelib/analysis/dctrcurv.c index ebde8055d..30d46296d 100644 --- a/src/spicelib/analysis/dctrcurv.c +++ b/src/spicelib/analysis/dctrcurv.c @@ -495,7 +495,7 @@ resume: if(firstTime) { firstTime=0; - bcopy(ckt->CKTstate0, ckt->CKTstate1, + memcpy(ckt->CKTstate1, ckt->CKTstate0, (size_t) ckt->CKTnumStates * sizeof(double)); } diff --git a/src/spicelib/devices/nbjt/nbjtset.c b/src/spicelib/devices/nbjt/nbjtset.c index 45b86db0b..71ea25bb9 100644 --- a/src/spicelib/devices/nbjt/nbjtset.c +++ b/src/spicelib/devices/nbjt/nbjtset.c @@ -191,7 +191,7 @@ NBJTsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states) pMaterial = pMaterial->next; } /* Copy everything, then fix the incorrect pointer. */ - bcopy(pM, pMaterial, sizeof(ONEmaterial)); + memcpy(pMaterial, pM, sizeof(ONEmaterial)); pMaterial->next = NULL; } diff --git a/src/spicelib/devices/nbjt/nbjttemp.c b/src/spicelib/devices/nbjt/nbjttemp.c index 13ed6717e..5620fec2c 100644 --- a/src/spicelib/devices/nbjt/nbjttemp.c +++ b/src/spicelib/devices/nbjt/nbjttemp.c @@ -76,7 +76,7 @@ NBJTtemp(GENmodel *inModel, CKTcircuit *ckt) /* Copy the original values, then fix the incorrect pointer. */ pNextMaterial = pMaterial->next; - bcopy(pM, pMaterial, sizeof(ONEmaterial)); + memcpy(pMaterial, pM, sizeof(ONEmaterial)); pMaterial->next = pNextMaterial; /* Now do the temperature dependence. */ diff --git a/src/spicelib/devices/nbjt2/nbt2set.c b/src/spicelib/devices/nbjt2/nbt2set.c index d52667ea6..e9094d7b7 100644 --- a/src/spicelib/devices/nbjt2/nbt2set.c +++ b/src/spicelib/devices/nbjt2/nbt2set.c @@ -213,7 +213,7 @@ NBJT2setup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states) pMaterial = pMaterial->next; } /* Copy everything, then fix the incorrect pointer. */ - bcopy(pM, pMaterial, sizeof(TWOmaterial)); + memcpy(pMaterial, pM, sizeof(TWOmaterial)); pMaterial->next = NULL; } diff --git a/src/spicelib/devices/nbjt2/nbt2temp.c b/src/spicelib/devices/nbjt2/nbt2temp.c index 48bdbd572..e0b52b08a 100644 --- a/src/spicelib/devices/nbjt2/nbt2temp.c +++ b/src/spicelib/devices/nbjt2/nbt2temp.c @@ -82,7 +82,7 @@ NBJT2temp(GENmodel *inModel, CKTcircuit *ckt) /* Copy everything, then fix the incorrect pointer. */ pNextMaterial = pMaterial->next; - bcopy(pM, pMaterial, sizeof(TWOmaterial)); + memcpy(pMaterial, pM, sizeof(TWOmaterial)); pMaterial->next = pNextMaterial; /* Now do the temperature dependence. */ diff --git a/src/spicelib/devices/numd/numdset.c b/src/spicelib/devices/numd/numdset.c index ed5b42314..a1b4d527f 100644 --- a/src/spicelib/devices/numd/numdset.c +++ b/src/spicelib/devices/numd/numdset.c @@ -186,7 +186,7 @@ NUMDsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states) pMaterial = pMaterial->next; } /* Copy everything, then fix the incorrect pointer. */ - bcopy(pM, pMaterial, sizeof(ONEmaterial)); + memcpy(pMaterial, pM, sizeof(ONEmaterial)); pMaterial->next = NULL; } diff --git a/src/spicelib/devices/numd/numdtemp.c b/src/spicelib/devices/numd/numdtemp.c index fd3dff0f3..d31d20acd 100644 --- a/src/spicelib/devices/numd/numdtemp.c +++ b/src/spicelib/devices/numd/numdtemp.c @@ -75,7 +75,7 @@ NUMDtemp(GENmodel *inModel, CKTcircuit *ckt) /* Copy the original values, then fix the incorrect pointer. */ pNextMaterial = pMaterial->next; - bcopy(pM, pMaterial, sizeof(ONEmaterial)); + memcpy(pMaterial, pM, sizeof(ONEmaterial)); pMaterial->next = pNextMaterial; /* Now do the temperature dependence. */ diff --git a/src/spicelib/devices/numd2/nud2set.c b/src/spicelib/devices/numd2/nud2set.c index c1074cac0..39a2b5ea2 100644 --- a/src/spicelib/devices/numd2/nud2set.c +++ b/src/spicelib/devices/numd2/nud2set.c @@ -211,7 +211,7 @@ NUMD2setup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states) pMaterial = pMaterial->next; } /* Copy everything, then fix the incorrect pointer. */ - bcopy(pM, pMaterial, sizeof(TWOmaterial)); + memcpy(pMaterial, pM, sizeof(TWOmaterial)); pMaterial->next = NULL; } diff --git a/src/spicelib/devices/numd2/nud2temp.c b/src/spicelib/devices/numd2/nud2temp.c index a0c416d97..bf68328fa 100644 --- a/src/spicelib/devices/numd2/nud2temp.c +++ b/src/spicelib/devices/numd2/nud2temp.c @@ -80,7 +80,7 @@ NUMD2temp(GENmodel *inModel, CKTcircuit *ckt) /* Copy everything, then fix the incorrect pointer. */ pNextMaterial = pMaterial->next; - bcopy(pM, pMaterial, sizeof(TWOmaterial)); + memcpy(pMaterial, pM, sizeof(TWOmaterial)); pMaterial->next = pNextMaterial; /* Now do the temperature dependence. */ diff --git a/src/spicelib/devices/numos/nummset.c b/src/spicelib/devices/numos/nummset.c index 046e8be8b..bfb10642a 100644 --- a/src/spicelib/devices/numos/nummset.c +++ b/src/spicelib/devices/numos/nummset.c @@ -210,7 +210,7 @@ NUMOSsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states) pMaterial = pMaterial->next; } /* Copy everything, then fix the incorrect pointer. */ - bcopy(pM, pMaterial, sizeof(TWOmaterial)); + memcpy(pMaterial, pM, sizeof(TWOmaterial)); pMaterial->next = NULL; } diff --git a/src/spicelib/devices/numos/nummtemp.c b/src/spicelib/devices/numos/nummtemp.c index 0a126fd0f..7765d5fa2 100644 --- a/src/spicelib/devices/numos/nummtemp.c +++ b/src/spicelib/devices/numos/nummtemp.c @@ -81,7 +81,7 @@ NUMOStemp(GENmodel *inModel, CKTcircuit *ckt) /* Copy everything, then fix the incorrect pointer. */ pNextMaterial = pMaterial->next; - bcopy(pM, pMaterial, sizeof(TWOmaterial)); + memcpy(pMaterial, pM, sizeof(TWOmaterial)); pMaterial->next = pNextMaterial; /* Now do the temperature dependence. */ diff --git a/visualc/src/include/ngspice/config.h b/visualc/src/include/ngspice/config.h index 31abfb5ca..2eff8f659 100644 --- a/visualc/src/include/ngspice/config.h +++ b/visualc/src/include/ngspice/config.h @@ -74,9 +74,6 @@ /* Define to 1 if you have the `atanh' function. */ /* #undef HAVE_ATANH */ -/* Define to 1 if you have the `bcopy' function. */ -/* #undef HAVE_BCOPY */ - /* Define to 1 if you have the header file. */ /* #undef HAVE_BLT_H */