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/63b9413d96a5
branches:  trunk
changeset: 495669:63b9413d96a5
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Wed Aug 02 20:53:07 2000 +0000

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

diffstat:

 sys/kern/tty_subr.c      |  12 ++++++------
 sys/kern/uipc_syscalls.c |  22 +++++++++++-----------
 2 files changed, 17 insertions(+), 17 deletions(-)

diffs (125 lines):

diff -r d64954748d08 -r 63b9413d96a5 sys/kern/tty_subr.c
--- a/sys/kern/tty_subr.c       Wed Aug 02 20:42:03 2000 +0000
+++ b/sys/kern/tty_subr.c       Wed Aug 02 20:53:07 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tty_subr.c,v 1.19 2000/03/30 09:27:13 augustss Exp $   */
+/*     $NetBSD: tty_subr.c,v 1.20 2000/08/02 20:53:07 thorpej Exp $    */
 
 /*
  * Copyright (c) 1993, 1994 Theo de Raadt
@@ -85,15 +85,15 @@
        int quot;
 {
 
-       MALLOC(clp->c_cs, u_char *, size, M_TTYS, M_WAITOK);
+       clp->c_cs = malloc(size, M_TTYS, M_WAITOK);
        if (!clp->c_cs)
                return (-1);
        memset(clp->c_cs, 0, size);
 
        if(quot) {
-               MALLOC(clp->c_cq, u_char *, QMEM(size), M_TTYS, M_WAITOK);
+               clp->c_cq = malloc(QMEM(size), M_TTYS, M_WAITOK);
                if (!clp->c_cq) {
-                       FREE(clp->c_cs, M_TTYS);
+                       free(clp->c_cs, M_TTYS);
                        return (-1);
                }
                memset(clp->c_cs, 0, QMEM(size));
@@ -112,9 +112,9 @@
        struct clist *clp;
 {
        if(clp->c_cs)
-               FREE(clp->c_cs, M_TTYS);
+               free(clp->c_cs, M_TTYS);
        if(clp->c_cq)
-               FREE(clp->c_cq, M_TTYS);
+               free(clp->c_cq, M_TTYS);
        clp->c_cs = clp->c_cq = (u_char *)0;
 }
 
diff -r d64954748d08 -r 63b9413d96a5 sys/kern/uipc_syscalls.c
--- a/sys/kern/uipc_syscalls.c  Wed Aug 02 20:42:03 2000 +0000
+++ b/sys/kern/uipc_syscalls.c  Wed Aug 02 20:53:07 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uipc_syscalls.c,v 1.53 2000/06/27 17:41:45 mrg Exp $   */
+/*     $NetBSD: uipc_syscalls.c,v 1.54 2000/08/02 20:56:52 thorpej Exp $       */
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1990, 1993
@@ -439,8 +439,8 @@
        if ((unsigned int)msg.msg_iovlen > UIO_SMALLIOV) {
                if ((unsigned int)msg.msg_iovlen > IOV_MAX)
                        return (EMSGSIZE);
-               MALLOC(iov, struct iovec *,
-                   sizeof(struct iovec) * msg.msg_iovlen, M_IOV, M_WAITOK);
+               iov = malloc(sizeof(struct iovec) * msg.msg_iovlen,
+                   M_IOV, M_WAITOK);
        } else
                iov = aiov;
        if ((unsigned int)msg.msg_iovlen > 0) {
@@ -456,7 +456,7 @@
        error = sendit(p, SCARG(uap, s), &msg, SCARG(uap, flags), retval);
 done:
        if (iov != aiov)
-               FREE(iov, M_IOV);
+               free(iov, M_IOV);
        return (error);
 }
 
@@ -551,7 +551,7 @@
        if (KTRPOINT(p, KTR_GENIO)) {
                int iovlen = auio.uio_iovcnt * sizeof(struct iovec);
 
-               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
@@ -571,7 +571,7 @@
        if (ktriov != NULL) {
                if (error == 0)
                        ktrgenio(p, s, UIO_WRITE, ktriov, *retsize, error);
-               FREE(ktriov, M_TEMP);
+               free(ktriov, M_TEMP);
        }
 #endif
  bad:
@@ -641,8 +641,8 @@
        if ((unsigned int)msg.msg_iovlen > UIO_SMALLIOV) {
                if ((unsigned int)msg.msg_iovlen > IOV_MAX)
                        return (EMSGSIZE);
-               MALLOC(iov, struct iovec *,
-                   sizeof(struct iovec) * msg.msg_iovlen, M_IOV, M_WAITOK);
+               iov = malloc(sizeof(struct iovec) * msg.msg_iovlen,
+                   M_IOV, M_WAITOK);
        } else
                iov = aiov;
        if ((unsigned int)msg.msg_iovlen > 0) {
@@ -665,7 +665,7 @@
        }
 done:
        if (iov != aiov)
-               FREE(iov, M_IOV);
+               free(iov, M_IOV);
        return (error);
 }
 
@@ -722,7 +722,7 @@
        if (KTRPOINT(p, KTR_GENIO)) {
                int iovlen = auio.uio_iovcnt * sizeof(struct iovec);
 
-               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
@@ -740,7 +740,7 @@
                if (error == 0)
                        ktrgenio(p, s, UIO_READ, ktriov,
                            len - auio.uio_resid, error);
-               FREE(ktriov, M_TEMP);
+               free(ktriov, M_TEMP);
        }
 #endif
        if (error)



Home | Main Index | Thread Index | Old Index