use memcpy() instead of deprecated bcopy()

This commit is contained in:
rlar 2016-07-23 09:13:55 +02:00
parent 9ab2960e87
commit 141ed61ec8
29 changed files with 39 additions and 60 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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;
*/
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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. */

View File

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

View File

@ -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. */

View File

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

View File

@ -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. */

View File

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

View File

@ -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. */

View File

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

View File

@ -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. */

View File

@ -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 <blt.h> header file. */
/* #undef HAVE_BLT_H */