Source-Changes-HG archive

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

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



details:   https://anonhg.NetBSD.org/src/rev/bcf5da940a83
branches:  trunk
changeset: 495696:bcf5da940a83
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Thu Aug 03 03:39:52 2000 +0000

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

diffstat:

 sys/isofs/cd9660/cd9660_vnops.c  |  7 +++----
 sys/miscfs/fdesc/fdesc_vnops.c   |  9 +++++----
 sys/miscfs/kernfs/kernfs_vnops.c |  7 +++----
 sys/miscfs/procfs/procfs_vnops.c |  8 ++++----
 sys/ntfs/ntfs_vnops.c            |  5 ++---
 5 files changed, 17 insertions(+), 19 deletions(-)

diffs (148 lines):

diff -r 793e4fff72b5 -r bcf5da940a83 sys/isofs/cd9660/cd9660_vnops.c
--- a/sys/isofs/cd9660/cd9660_vnops.c   Thu Aug 03 03:39:02 2000 +0000
+++ b/sys/isofs/cd9660/cd9660_vnops.c   Thu Aug 03 03:39:52 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cd9660_vnops.c,v 1.58 2000/05/27 16:03:56 jdolecek Exp $       */
+/*     $NetBSD: cd9660_vnops.c,v 1.59 2000/08/03 03:39:52 thorpej Exp $        */
 
 /*-
  * Copyright (c) 1994
@@ -469,8 +469,7 @@
                idp->cookies = NULL;
        else {
                ncookies = uio->uio_resid / 16;
-               MALLOC(cookies, off_t *, ncookies * sizeof(off_t), M_TEMP,
-                   M_WAITOK);
+               cookies = malloc(ncookies * sizeof(off_t), M_TEMP, M_WAITOK);
                idp->cookies = cookies;
                idp->ncookies = ncookies;
        }
@@ -591,7 +590,7 @@
 
        if (ap->a_ncookies != NULL) {
                if (error)
-                       FREE(cookies, M_TEMP);
+                       free(cookies, M_TEMP);
                else {
                        /*
                         * Work out the number of cookies actually used.
diff -r 793e4fff72b5 -r bcf5da940a83 sys/miscfs/fdesc/fdesc_vnops.c
--- a/sys/miscfs/fdesc/fdesc_vnops.c    Thu Aug 03 03:39:02 2000 +0000
+++ b/sys/miscfs/fdesc/fdesc_vnops.c    Thu Aug 03 03:39:52 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fdesc_vnops.c,v 1.55 2000/05/27 04:52:39 thorpej Exp $ */
+/*     $NetBSD: fdesc_vnops.c,v 1.56 2000/08/03 03:41:17 thorpej Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -725,7 +725,7 @@
 
                if (ap->a_ncookies) {
                        ncookies = min(ncookies, (nfdesc_targets - i));
-                       MALLOC(cookies, off_t *, ncookies * sizeof(off_t),
+                       cookies = malloc(ncookies * sizeof(off_t),
                            M_TEMP, M_WAITOK);
                        *ap->a_cookies = cookies;
                        *ap->a_ncookies = ncookies;
@@ -762,7 +762,8 @@
        } else {
                if (ap->a_ncookies) {
                        ncookies = min(ncookies, (fdp->fd_nfiles + 2));
-                       MALLOC(cookies, off_t *, ncookies * sizeof(off_t),                                  M_TEMP, M_WAITOK);
+                       cookies = malloc(ncookies * sizeof(off_t),
+                           M_TEMP, M_WAITOK);
                        *ap->a_cookies = cookies;
                        *ap->a_ncookies = ncookies;
                }
@@ -795,7 +796,7 @@
        }
 
        if (ap->a_ncookies && error) {
-               FREE(*ap->a_cookies, M_TEMP);
+               free(*ap->a_cookies, M_TEMP);
                *ap->a_ncookies = 0;
                *ap->a_cookies = NULL;
        }
diff -r 793e4fff72b5 -r bcf5da940a83 sys/miscfs/kernfs/kernfs_vnops.c
--- a/sys/miscfs/kernfs/kernfs_vnops.c  Thu Aug 03 03:39:02 2000 +0000
+++ b/sys/miscfs/kernfs/kernfs_vnops.c  Thu Aug 03 03:39:52 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kernfs_vnops.c,v 1.69 2000/07/14 07:21:50 thorpej Exp $        */
+/*     $NetBSD: kernfs_vnops.c,v 1.70 2000/08/03 03:41:18 thorpej Exp $        */
 
 /*
  * Copyright (c) 1992, 1993
@@ -638,8 +638,7 @@
        if (ap->a_ncookies) {
                nc = uio->uio_resid / UIO_MX;
                nc = min(nc, (nkern_targets - i));
-               MALLOC(cookies, off_t *, nc * sizeof(off_t), M_TEMP,
-                   M_WAITOK);
+               cookies = malloc(nc * sizeof(off_t), M_TEMP, M_WAITOK);
                *ap->a_cookies = cookies;
        }
 
@@ -672,7 +671,7 @@
 
        if (ap->a_ncookies) {
                if (error) {
-                       FREE(*ap->a_cookies, M_TEMP);
+                       free(*ap->a_cookies, M_TEMP);
                        *ap->a_ncookies = 0;
                        *ap->a_cookies = NULL;
                } else
diff -r 793e4fff72b5 -r bcf5da940a83 sys/miscfs/procfs/procfs_vnops.c
--- a/sys/miscfs/procfs/procfs_vnops.c  Thu Aug 03 03:39:02 2000 +0000
+++ b/sys/miscfs/procfs/procfs_vnops.c  Thu Aug 03 03:39:52 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: procfs_vnops.c,v 1.71 2000/06/28 02:44:07 mrg Exp $    */
+/*     $NetBSD: procfs_vnops.c,v 1.72 2000/08/03 03:41:18 thorpej Exp $        */
 
 /*
  * Copyright (c) 1993 Jan-Simon Pendry
@@ -894,7 +894,7 @@
 
                if (ap->a_ncookies) {
                        ncookies = min(ncookies, (nproc_targets - i));
-                       MALLOC(cookies, off_t *, ncookies * sizeof (off_t),
+                       cookies = malloc(ncookies * sizeof (off_t),
                            M_TEMP, M_WAITOK);
                        *ap->a_cookies = cookies;
                }
@@ -940,7 +940,7 @@
                         * XXX Potentially allocating too much space here,
                         * but I'm lazy. This loop needs some work.
                         */
-                       MALLOC(cookies, off_t *, ncookies * sizeof (off_t),
+                       cookies = malloc(ncookies * sizeof (off_t),
                            M_TEMP, M_WAITOK);
                        *ap->a_cookies = cookies;
                }
@@ -1022,7 +1022,7 @@
        if (ap->a_ncookies) {
                if (error) {
                        if (cookies)
-                               FREE(*ap->a_cookies, M_TEMP);
+                               free(*ap->a_cookies, M_TEMP);
                        *ap->a_ncookies = 0;
                        *ap->a_cookies = NULL;
                } else
diff -r 793e4fff72b5 -r bcf5da940a83 sys/ntfs/ntfs_vnops.c
--- a/sys/ntfs/ntfs_vnops.c     Thu Aug 03 03:39:02 2000 +0000
+++ b/sys/ntfs/ntfs_vnops.c     Thu Aug 03 03:39:52 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ntfs_vnops.c,v 1.28 2000/07/30 09:29:28 simonb Exp $   */
+/*     $NetBSD: ntfs_vnops.c,v 1.29 2000/08/03 03:41:54 thorpej Exp $  */
 
 /*
  * Copyright (c) 1992, 1993
@@ -686,8 +686,7 @@
                MALLOC(cookies, u_long *, ncookies * sizeof(u_long),
                       M_TEMP, M_WAITOK);
 #else /* defined(__NetBSD__) */
-               MALLOC(cookies, off_t *, ncookies * sizeof(off_t),
-                      M_TEMP, M_WAITOK);
+               cookies = malloc(ncookies * sizeof(off_t), M_TEMP, M_WAITOK);
 #endif
                for (dp = dpStart, cookiep = cookies, i=0;
                     i < ncookies;



Home | Main Index | Thread Index | Old Index