Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern MALLOC()/FREE() are not to be used for variable siz...



details:   https://anonhg.NetBSD.org/src/rev/d64954748d08
branches:  trunk
changeset: 495668:d64954748d08
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Wed Aug 02 20:42:03 2000 +0000

description:
MALLOC()/FREE() are not to be used for variable sized allocations.

diffstat:

 sys/kern/exec_subr.c   |  13 +++++++------
 sys/kern/sys_generic.c |  18 +++++++++---------
 2 files changed, 16 insertions(+), 15 deletions(-)

diffs (114 lines):

diff -r 2ff7a2f716be -r d64954748d08 sys/kern/exec_subr.c
--- a/sys/kern/exec_subr.c      Wed Aug 02 20:36:33 2000 +0000
+++ b/sys/kern/exec_subr.c      Wed Aug 02 20:42:03 2000 +0000
@@ -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 @@
        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 @@
                        vrele(vcp->ev_vp);
        }
        evsp->evs_used = evsp->evs_cnt = 0;
-       FREE(evsp->evs_cmds, M_EXEC);
+       free(evsp->evs_cmds, M_EXEC);
 }
 
 /*
diff -r 2ff7a2f716be -r d64954748d08 sys/kern/sys_generic.c
--- a/sys/kern/sys_generic.c    Wed Aug 02 20:36:33 2000 +0000
+++ b/sys/kern/sys_generic.c    Wed Aug 02 20:42:03 2000 +0000
@@ -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 @@
                        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 @@
         * 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 @@
        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 @@
        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 @@
         * 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 @@
        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);



Home | Main Index | Thread Index | Old Index