Browse Source

use memcpy() instead of deprecated bcopy()

pre-master-46
rlar 10 years ago
parent
commit
141ed61ec8
  1. 2
      configure.ac
  2. 2
      src/ciderlib/support/database.c
  3. 4
      src/frontend/com_let.c
  4. 8
      src/frontend/define.c
  5. 2
      src/frontend/gens.c
  6. 2
      src/frontend/plotting/agraf.c
  7. 2
      src/frontend/plotting/graphdb.c
  8. 4
      src/frontend/plotting/plotcurv.c
  9. 4
      src/frontend/plotting/plotit.c
  10. 4
      src/frontend/postcoms.c
  11. 4
      src/frontend/variable.c
  12. 10
      src/frontend/vectors.c
  13. 4
      src/include/ngspice/stringutil.h
  14. 4
      src/maths/poly/interpolate.c
  15. 14
      src/misc/string.c
  16. 2
      src/spicelib/analysis/dcpss.c
  17. 2
      src/spicelib/analysis/dctran.c
  18. 2
      src/spicelib/analysis/dctrcurv.c
  19. 2
      src/spicelib/devices/nbjt/nbjtset.c
  20. 2
      src/spicelib/devices/nbjt/nbjttemp.c
  21. 2
      src/spicelib/devices/nbjt2/nbt2set.c
  22. 2
      src/spicelib/devices/nbjt2/nbt2temp.c
  23. 2
      src/spicelib/devices/numd/numdset.c
  24. 2
      src/spicelib/devices/numd/numdtemp.c
  25. 2
      src/spicelib/devices/numd2/nud2set.c
  26. 2
      src/spicelib/devices/numd2/nud2temp.c
  27. 2
      src/spicelib/devices/numos/nummset.c
  28. 2
      src/spicelib/devices/numos/nummtemp.c
  29. 3
      visualc/src/include/ngspice/config.h

2
configure.ac

@ -712,7 +712,7 @@ AC_CHECK_FUNCS([isatty tcgetattr tcsetattr])
# Check for a few functions: # Check for a few functions:
AC_FUNC_FORK([]) 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([strchr index], [break])
AC_CHECK_FUNCS([strrchr rindex], [break]) AC_CHECK_FUNCS([strrchr rindex], [break])
AC_CHECK_FUNCS([getcwd getwd], [break]) AC_CHECK_FUNCS([getcwd getwd], [break])

2
src/ciderlib/support/database.c

@ -38,7 +38,7 @@ DBgetData(struct plot *plot, char *name, int lengthWanted)
data = TMALLOC(double, v->v_length); data = TMALLOC(double, v->v_length);
if (isreal(v)) { 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 { } else {
for (i=0; i < v->v_length; i++) { for (i=0; i < v->v_length; i++) {
data[i] = realpart(v->v_compdata[i]); data[i] = realpart(v->v_compdata[i]);

4
src/frontend/com_let.c

@ -218,10 +218,10 @@ com_let(wordlist *wl)
n->v_flags &= ~VF_PERMANENT; n->v_flags &= ~VF_PERMANENT;
goto quit; goto quit;
} else if (isreal(t)) { } 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)); (size_t) length * sizeof(double));
} else { } else {
bcopy(t->v_compdata, n->v_compdata + offset,
memcpy(n->v_compdata + offset, t->v_compdata,
(size_t) length * sizeof(ngcomplex_t)); (size_t) length * sizeof(ngcomplex_t));
} }

8
src/frontend/define.c

@ -169,12 +169,12 @@ savetree(struct pnode *pn)
/* this dvec isn't member of any plot */ /* this dvec isn't member of any plot */
if (isreal(d)) { 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); sizeof(double) * (size_t) d->v_length);
} else { } 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); sizeof(ngcomplex_t) * (size_t) d->v_length);
} }
} }

2
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; int dnum, i, j, k;
dgxp = &dgx; 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; dnum = dgxp->dev_type_no;

2
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; field[k * omaxy + i] = LCHAR;
line1[i + margin + 2 * shift] = '|'; line1[i + margin + 2 * shift] = '|';
(void) sprintf(buf, "%.2e", j * pow(10.0, (double) mag)); (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)); strlen(buf));
} }
line1[i - spacing + margin + 1] = '\0'; line1[i - spacing + margin + 1] = '\0';

2
src/frontend/plotting/graphdb.c

@ -110,7 +110,7 @@ CopyGraph(GRAPH *graph)
struct dveclist *link, *newlink; struct dveclist *link, *newlink;
ret = NewGraph(); 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 */ ret->graphid = RunningId - 1; /* restore id */

4
src/frontend/plotting/plotcurv.c

@ -219,13 +219,13 @@ ft_graf(struct dvec *v, struct dvec *xs, bool nostart)
/* Plot the first degree segments... */ /* Plot the first degree segments... */
if (isreal(v)) 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 else
for (i = 0; i <= degree; i++) for (i = 0; i <= degree; i++)
ydata[i] = realpart(v->v_compdata[i]); ydata[i] = realpart(v->v_compdata[i]);
if (isreal(xs)) 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 else
for (i = 0; i <= degree; i++) for (i = 0; i <= degree; i++)
xdata[i] = realpart(xs->v_compdata[i]); xdata[i] = realpart(xs->v_compdata[i]);

4
src/frontend/plotting/plotit.c

@ -131,11 +131,11 @@ compress(struct dvec *d, double *xcomp, double *xind)
newlen = ihi - ilo; newlen = ihi - ilo;
if (isreal(d)) { if (isreal(d)) {
double *dd = TMALLOC(double, newlen); 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); dvec_realloc(d, newlen, dd);
} else { } else {
ngcomplex_t *cc = TMALLOC(ngcomplex_t, newlen); 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); dvec_realloc(d, newlen, cc);
} }
} }

4
src/frontend/postcoms.c

@ -433,7 +433,7 @@ com_write(wordlist *wl)
tpl = vecs->v_plot; tpl = vecs->v_plot;
tpl->pl_written = TRUE; tpl->pl_written = TRUE;
end = NULL; end = NULL;
bcopy(tpl, &newplot, sizeof(struct plot));
memcpy(&newplot, tpl, sizeof(struct plot));
scalefound = FALSE; scalefound = FALSE;
/* Figure out how many vectors are in this plot. Also look /* 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 = vecs->v_plot;
tpl->pl_written = TRUE; tpl->pl_written = TRUE;
end = NULL; end = NULL;
bcopy(tpl, &newplot, sizeof(struct plot));
memcpy(&newplot, tpl, sizeof(struct plot));
scalefound = FALSE; scalefound = FALSE;
/* Figure out how many vectors are in this plot. Also look /* Figure out how many vectors are in this plot. Also look

4
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; v->va_next = ft_curckt->ci_vars;
ft_curckt->ci_vars = v; ft_curckt->ci_vars = v;
} else { } else {
/* va: avoid memory leak within bcopy */
/* va: avoid memory leak within memcpy */
if (u->va_type == CP_STRING) if (u->va_type == CP_STRING)
tfree(u->va_string); tfree(u->va_string);
else if (u->va_type == CP_LIST) else if (u->va_type == CP_LIST)
@ -233,7 +233,7 @@ cp_vset(char *varname, enum cp_types type, void *value)
tfree(v); tfree(v);
/* va: old version with memory leaks /* va: old version with memory leaks
w = u->va_next; w = u->va_next;
bcopy(v, u, sizeof(*u));
memcpy(u, v, sizeof(*u));
u->va_next = w; u->va_next = w;
*/ */
} }

10
src/frontend/vectors.c

@ -687,10 +687,10 @@ vec_copy(struct dvec *v)
v->v_length, NULL); v->v_length, NULL);
if (isreal(v)) if (isreal(v))
bcopy(v->v_realdata, nv->v_realdata,
memcpy(nv->v_realdata, v->v_realdata,
sizeof(double) * (size_t) v->v_length); sizeof(double) * (size_t) v->v_length);
else else
bcopy(v->v_compdata, nv->v_compdata,
memcpy(nv->v_compdata, v->v_compdata,
sizeof(ngcomplex_t) * (size_t) v->v_length); sizeof(ngcomplex_t) * (size_t) v->v_length);
nv->v_minsignal = v->v_minsignal; nv->v_minsignal = v->v_minsignal;
@ -1031,7 +1031,7 @@ vec_transpose(struct dvec *v)
* newa[j,i] is at data[j*dim1+i] * newa[j,i] is at data[j*dim1+i]
* where j is in [0, dim0-1] and i is in [0, dim1-1] * 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 * 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 * though. The formulation below gathers scattered old data into
* consecutive new data. * consecutive new data.
*/ */
@ -1113,9 +1113,9 @@ vec_mkfamily(struct dvec *v)
d->v_dims[0] = size; d->v_dims[0] = size;
if (isreal(v)) { 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 { } 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. */ /* Add one to the counter. */
(void) incindex(count, v->v_numdims - 1, v->v_dims, v->v_numdims); (void) incindex(count, v->v_numdims - 1, v->v_dims, v->v_numdims);

4
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); int cimatch(register char *p, register char *s);
#endif #endif
#ifndef HAVE_BCOPY
void bcopy(const void *from, void *to, size_t num);
#endif
#ifndef HAVE_BZERO #ifndef HAVE_BZERO
void bzero(void *ptr, size_t num); void bzero(void *ptr, size_t num);
#endif #endif

4
src/maths/poly/interpolate.c

@ -60,8 +60,8 @@ ft_interpolate(double *data, double *ndata, double *oscale, int olen,
ydata = TMALLOC(double, degree + 1); ydata = TMALLOC(double, degree + 1);
/* Deal with the first degree pieces. */ /* 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)) { while (!ft_polyfit(xdata, ydata, result, degree, scratch)) {
/* If it doesn't work this time, bump the interpolation /* If it doesn't work this time, bump the interpolation

14
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 HAVE_BZERO
#ifndef bzero #ifndef bzero
void void

2
src/spicelib/analysis/dcpss.c

@ -390,7 +390,7 @@ DCpss(CKTcircuit *ckt,
ckt->CKTag[0]=ckt->CKTag[1]=0; ckt->CKTag[0]=ckt->CKTag[1]=0;
/* State0 copied into State1 - DEPRECATED LEGACY function - to be replaced with memmove() */ /* 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)); (size_t) ckt->CKTnumStates * sizeof(double));
/* Statistics Initialization using a macro at the beginning of this code */ /* Statistics Initialization using a macro at the beginning of this code */

2
src/spicelib/analysis/dctran.c

@ -341,7 +341,7 @@ DCtran(CKTcircuit *ckt,
ckt->CKTmode = (ckt->CKTmode&MODEUIC) | MODETRAN | MODEINITTRAN; ckt->CKTmode = (ckt->CKTmode&MODEUIC) | MODETRAN | MODEINITTRAN;
/* modeinittran set here */ /* modeinittran set here */
ckt->CKTag[0]=ckt->CKTag[1]=0; ckt->CKTag[0]=ckt->CKTag[1]=0;
bcopy(ckt->CKTstate0, ckt->CKTstate1,
memcpy(ckt->CKTstate1, ckt->CKTstate0,
(size_t) ckt->CKTnumStates * sizeof(double)); (size_t) ckt->CKTnumStates * sizeof(double));
#ifdef WANT_SENSE2 #ifdef WANT_SENSE2

2
src/spicelib/analysis/dctrcurv.c

@ -495,7 +495,7 @@ resume:
if(firstTime) { if(firstTime) {
firstTime=0; firstTime=0;
bcopy(ckt->CKTstate0, ckt->CKTstate1,
memcpy(ckt->CKTstate1, ckt->CKTstate0,
(size_t) ckt->CKTnumStates * sizeof(double)); (size_t) ckt->CKTnumStates * sizeof(double));
} }

2
src/spicelib/devices/nbjt/nbjtset.c

@ -191,7 +191,7 @@ NBJTsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
pMaterial = pMaterial->next; pMaterial = pMaterial->next;
} }
/* Copy everything, then fix the incorrect pointer. */ /* Copy everything, then fix the incorrect pointer. */
bcopy(pM, pMaterial, sizeof(ONEmaterial));
memcpy(pMaterial, pM, sizeof(ONEmaterial));
pMaterial->next = NULL; pMaterial->next = NULL;
} }

2
src/spicelib/devices/nbjt/nbjttemp.c

@ -76,7 +76,7 @@ NBJTtemp(GENmodel *inModel, CKTcircuit *ckt)
/* Copy the original values, then fix the incorrect pointer. */ /* Copy the original values, then fix the incorrect pointer. */
pNextMaterial = pMaterial->next; pNextMaterial = pMaterial->next;
bcopy(pM, pMaterial, sizeof(ONEmaterial));
memcpy(pMaterial, pM, sizeof(ONEmaterial));
pMaterial->next = pNextMaterial; pMaterial->next = pNextMaterial;
/* Now do the temperature dependence. */ /* Now do the temperature dependence. */

2
src/spicelib/devices/nbjt2/nbt2set.c

@ -213,7 +213,7 @@ NBJT2setup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
pMaterial = pMaterial->next; pMaterial = pMaterial->next;
} }
/* Copy everything, then fix the incorrect pointer. */ /* Copy everything, then fix the incorrect pointer. */
bcopy(pM, pMaterial, sizeof(TWOmaterial));
memcpy(pMaterial, pM, sizeof(TWOmaterial));
pMaterial->next = NULL; pMaterial->next = NULL;
} }

2
src/spicelib/devices/nbjt2/nbt2temp.c

@ -82,7 +82,7 @@ NBJT2temp(GENmodel *inModel, CKTcircuit *ckt)
/* Copy everything, then fix the incorrect pointer. */ /* Copy everything, then fix the incorrect pointer. */
pNextMaterial = pMaterial->next; pNextMaterial = pMaterial->next;
bcopy(pM, pMaterial, sizeof(TWOmaterial));
memcpy(pMaterial, pM, sizeof(TWOmaterial));
pMaterial->next = pNextMaterial; pMaterial->next = pNextMaterial;
/* Now do the temperature dependence. */ /* Now do the temperature dependence. */

2
src/spicelib/devices/numd/numdset.c

@ -186,7 +186,7 @@ NUMDsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
pMaterial = pMaterial->next; pMaterial = pMaterial->next;
} }
/* Copy everything, then fix the incorrect pointer. */ /* Copy everything, then fix the incorrect pointer. */
bcopy(pM, pMaterial, sizeof(ONEmaterial));
memcpy(pMaterial, pM, sizeof(ONEmaterial));
pMaterial->next = NULL; pMaterial->next = NULL;
} }

2
src/spicelib/devices/numd/numdtemp.c

@ -75,7 +75,7 @@ NUMDtemp(GENmodel *inModel, CKTcircuit *ckt)
/* Copy the original values, then fix the incorrect pointer. */ /* Copy the original values, then fix the incorrect pointer. */
pNextMaterial = pMaterial->next; pNextMaterial = pMaterial->next;
bcopy(pM, pMaterial, sizeof(ONEmaterial));
memcpy(pMaterial, pM, sizeof(ONEmaterial));
pMaterial->next = pNextMaterial; pMaterial->next = pNextMaterial;
/* Now do the temperature dependence. */ /* Now do the temperature dependence. */

2
src/spicelib/devices/numd2/nud2set.c

@ -211,7 +211,7 @@ NUMD2setup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
pMaterial = pMaterial->next; pMaterial = pMaterial->next;
} }
/* Copy everything, then fix the incorrect pointer. */ /* Copy everything, then fix the incorrect pointer. */
bcopy(pM, pMaterial, sizeof(TWOmaterial));
memcpy(pMaterial, pM, sizeof(TWOmaterial));
pMaterial->next = NULL; pMaterial->next = NULL;
} }

2
src/spicelib/devices/numd2/nud2temp.c

@ -80,7 +80,7 @@ NUMD2temp(GENmodel *inModel, CKTcircuit *ckt)
/* Copy everything, then fix the incorrect pointer. */ /* Copy everything, then fix the incorrect pointer. */
pNextMaterial = pMaterial->next; pNextMaterial = pMaterial->next;
bcopy(pM, pMaterial, sizeof(TWOmaterial));
memcpy(pMaterial, pM, sizeof(TWOmaterial));
pMaterial->next = pNextMaterial; pMaterial->next = pNextMaterial;
/* Now do the temperature dependence. */ /* Now do the temperature dependence. */

2
src/spicelib/devices/numos/nummset.c

@ -210,7 +210,7 @@ NUMOSsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
pMaterial = pMaterial->next; pMaterial = pMaterial->next;
} }
/* Copy everything, then fix the incorrect pointer. */ /* Copy everything, then fix the incorrect pointer. */
bcopy(pM, pMaterial, sizeof(TWOmaterial));
memcpy(pMaterial, pM, sizeof(TWOmaterial));
pMaterial->next = NULL; pMaterial->next = NULL;
} }

2
src/spicelib/devices/numos/nummtemp.c

@ -81,7 +81,7 @@ NUMOStemp(GENmodel *inModel, CKTcircuit *ckt)
/* Copy everything, then fix the incorrect pointer. */ /* Copy everything, then fix the incorrect pointer. */
pNextMaterial = pMaterial->next; pNextMaterial = pMaterial->next;
bcopy(pM, pMaterial, sizeof(TWOmaterial));
memcpy(pMaterial, pM, sizeof(TWOmaterial));
pMaterial->next = pNextMaterial; pMaterial->next = pNextMaterial;
/* Now do the temperature dependence. */ /* Now do the temperature dependence. */

3
visualc/src/include/ngspice/config.h

@ -74,9 +74,6 @@
/* Define to 1 if you have the `atanh' function. */ /* Define to 1 if you have the `atanh' function. */
/* #undef HAVE_ATANH */ /* #undef HAVE_ATANH */
/* Define to 1 if you have the `bcopy' function. */
/* #undef HAVE_BCOPY */
/* Define to 1 if you have the <blt.h> header file. */ /* Define to 1 if you have the <blt.h> header file. */
/* #undef HAVE_BLT_H */ /* #undef HAVE_BLT_H */

Loading…
Cancel
Save