MALLOC()/FREE() are not to be used for variable sized allocations.
This commit is contained in:
parent
0b3ef940d0
commit
c80a866888
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: exec_subr.c,v 1.22 2000/08/01 04:57:29 thorpej Exp $ */
|
||||
/* $NetBSD: exec_subr.c,v 1.23 2000/08/02 20:42:03 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1993, 1994, 1996 Christopher G. Demetriou
|
||||
@ -94,13 +94,14 @@ vmcmdset_extend(struct exec_vmcmd_set *evsp)
|
||||
evsp->evs_cnt += ocnt ? ocnt : EXEC_DEFAULT_VMCMD_SETSIZE;
|
||||
|
||||
/* allocate it */
|
||||
MALLOC(nvcp, struct exec_vmcmd *,
|
||||
(evsp->evs_cnt * sizeof(struct exec_vmcmd)), M_EXEC, M_WAITOK);
|
||||
nvcp = malloc(evsp->evs_cnt * sizeof(struct exec_vmcmd),
|
||||
M_EXEC, M_WAITOK);
|
||||
|
||||
/* free the old struct, if there was one, and record the new one */
|
||||
if (ocnt) {
|
||||
memcpy(nvcp, evsp->evs_cmds, (ocnt * sizeof(struct exec_vmcmd)));
|
||||
FREE(evsp->evs_cmds, M_EXEC);
|
||||
memcpy(nvcp, evsp->evs_cmds,
|
||||
(ocnt * sizeof(struct exec_vmcmd)));
|
||||
free(evsp->evs_cmds, M_EXEC);
|
||||
}
|
||||
evsp->evs_cmds = nvcp;
|
||||
}
|
||||
@ -120,7 +121,7 @@ kill_vmcmds(struct exec_vmcmd_set *evsp)
|
||||
vrele(vcp->ev_vp);
|
||||
}
|
||||
evsp->evs_used = evsp->evs_cnt = 0;
|
||||
FREE(evsp->evs_cmds, M_EXEC);
|
||||
free(evsp->evs_cmds, M_EXEC);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: sys_generic.c,v 1.49 2000/07/13 01:32:33 thorpej Exp $ */
|
||||
/* $NetBSD: sys_generic.c,v 1.50 2000/08/02 20:48:37 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1989, 1993
|
||||
@ -217,7 +217,7 @@ dofilereadv(p, fd, fp, iovp, iovcnt, offset, flags, retval)
|
||||
error = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
MALLOC(iov, struct iovec *, iovlen, M_IOV, M_WAITOK);
|
||||
iov = malloc(iovlen, M_IOV, M_WAITOK);
|
||||
needfree = iov;
|
||||
} else if ((u_int)iovcnt > 0) {
|
||||
iov = aiov;
|
||||
@ -254,7 +254,7 @@ dofilereadv(p, fd, fp, iovp, iovcnt, offset, flags, retval)
|
||||
* if tracing, save a copy of iovec
|
||||
*/
|
||||
if (KTRPOINT(p, KTR_GENIO)) {
|
||||
MALLOC(ktriov, struct iovec *, iovlen, M_TEMP, M_WAITOK);
|
||||
ktriov = malloc(iovlen, M_TEMP, M_WAITOK);
|
||||
memcpy((caddr_t)ktriov, (caddr_t)auio.uio_iov, iovlen);
|
||||
}
|
||||
#endif
|
||||
@ -269,13 +269,13 @@ dofilereadv(p, fd, fp, iovp, iovcnt, offset, flags, retval)
|
||||
if (KTRPOINT(p, KTR_GENIO))
|
||||
if (error == 0) {
|
||||
ktrgenio(p, fd, UIO_READ, ktriov, cnt, error);
|
||||
FREE(ktriov, M_TEMP);
|
||||
free(ktriov, M_TEMP);
|
||||
}
|
||||
#endif
|
||||
*retval = cnt;
|
||||
done:
|
||||
if (needfree)
|
||||
FREE(needfree, M_IOV);
|
||||
free(needfree, M_IOV);
|
||||
out:
|
||||
FILE_UNUSE(fp, p);
|
||||
return (error);
|
||||
@ -433,7 +433,7 @@ dofilewritev(p, fd, fp, iovp, iovcnt, offset, flags, retval)
|
||||
if ((u_int)iovcnt > UIO_SMALLIOV) {
|
||||
if ((u_int)iovcnt > IOV_MAX)
|
||||
return (EINVAL);
|
||||
MALLOC(iov, struct iovec *, iovlen, M_IOV, M_WAITOK);
|
||||
iov = malloc(iovlen, M_IOV, M_WAITOK);
|
||||
needfree = iov;
|
||||
} else if ((u_int)iovcnt > 0) {
|
||||
iov = aiov;
|
||||
@ -470,7 +470,7 @@ dofilewritev(p, fd, fp, iovp, iovcnt, offset, flags, retval)
|
||||
* if tracing, save a copy of iovec
|
||||
*/
|
||||
if (KTRPOINT(p, KTR_GENIO)) {
|
||||
MALLOC(ktriov, struct iovec *, iovlen, M_TEMP, M_WAITOK);
|
||||
ktriov = malloc(iovlen, M_TEMP, M_WAITOK);
|
||||
memcpy((caddr_t)ktriov, (caddr_t)auio.uio_iov, iovlen);
|
||||
}
|
||||
#endif
|
||||
@ -488,13 +488,13 @@ dofilewritev(p, fd, fp, iovp, iovcnt, offset, flags, retval)
|
||||
if (KTRPOINT(p, KTR_GENIO))
|
||||
if (error == 0) {
|
||||
ktrgenio(p, fd, UIO_WRITE, ktriov, cnt, error);
|
||||
FREE(ktriov, M_TEMP);
|
||||
free(ktriov, M_TEMP);
|
||||
}
|
||||
#endif
|
||||
*retval = cnt;
|
||||
done:
|
||||
if (needfree)
|
||||
FREE(needfree, M_IOV);
|
||||
free(needfree, M_IOV);
|
||||
out:
|
||||
FILE_UNUSE(fp, p);
|
||||
return (error);
|
||||
|
Loading…
x
Reference in New Issue
Block a user