diff options
author | 2000-09-27 16:13:46 +0000 | |
---|---|---|
committer | 2000-09-27 16:13:46 +0000 | |
commit | 8b34068e3e730441ed86d2ec9a829c83b96323e0 (patch) | |
tree | 03808780c08fc54ab40551a5b64804b25164e66a | |
parent | Minimal optimization. (diff) | |
download | wireguard-openbsd-8b34068e3e730441ed86d2ec9a829c83b96323e0.tar.xz wireguard-openbsd-8b34068e3e730441ed86d2ec9a829c83b96323e0.zip |
replace MALLOC/FREE w/ malloc/free for non-constant-sized memory allocations; art@ ok
-rw-r--r-- | sys/kern/kern_descrip.c | 30 | ||||
-rw-r--r-- | sys/kern/kern_ktrace.c | 10 | ||||
-rw-r--r-- | sys/kern/sys_generic.c | 20 | ||||
-rw-r--r-- | sys/kern/tty_subr.c | 12 | ||||
-rw-r--r-- | sys/kern/uipc_syscalls.c | 22 | ||||
-rw-r--r-- | sys/kern/vfs_init.c | 6 |
6 files changed, 47 insertions, 53 deletions
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index 31109d62dd4..48027b553b3 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_descrip.c,v 1.21 2000/09/24 19:13:26 provos Exp $ */ +/* $OpenBSD: kern_descrip.c,v 1.22 2000/09/27 16:13:46 mickey Exp $ */ /* $NetBSD: kern_descrip.c,v 1.42 1996/03/30 22:24:38 christos Exp $ */ /* @@ -646,8 +646,7 @@ fdalloc(p, want, result) else nfiles = 2 * fdp->fd_nfiles; nfiles = min(lim, nfiles); - MALLOC(newofile, struct file **, nfiles * OFILESIZE, - M_FILEDESC, M_WAITOK); + newofile = malloc(nfiles * OFILESIZE, M_FILEDESC, M_WAITOK); newofileflags = (char *) &newofile[nfiles]; /* @@ -662,14 +661,12 @@ fdalloc(p, want, result) bzero(newofileflags + i, nfiles * sizeof(char) - i); if (fdp->fd_nfiles > NDFILE) - FREE(fdp->fd_ofiles, M_FILEDESC); + free(fdp->fd_ofiles, M_FILEDESC); if (NDHISLOTS(nfiles) > NDHISLOTS(fdp->fd_nfiles)) { - MALLOC(newhimap, u_int *, - NDHISLOTS(nfiles) * sizeof(u_int), + newhimap = malloc(NDHISLOTS(nfiles) * sizeof(u_int), M_FILEDESC, M_WAITOK); - MALLOC(newlomap, u_int *, - NDLOSLOTS(nfiles) * sizeof(u_int), + newlomap = malloc( NDLOSLOTS(nfiles) * sizeof(u_int), M_FILEDESC, M_WAITOK); bcopy(fdp->fd_himap, newhimap, @@ -683,8 +680,8 @@ fdalloc(p, want, result) NDLOSLOTS(nfiles) * sizeof(u_int) - i); if (NDHISLOTS(fdp->fd_nfiles) > NDHISLOTS(NDFILE)) { - FREE(fdp->fd_himap, M_FILEDESC); - FREE(fdp->fd_lomap, M_FILEDESC); + free(fdp->fd_himap, M_FILEDESC); + free(fdp->fd_lomap, M_FILEDESC); } fdp->fd_himap = newhimap; fdp->fd_lomap = newlomap; @@ -865,8 +862,7 @@ fdcopy(p) i = newfdp->fd_nfiles; while (i >= 2 * NDEXTENT && i > newfdp->fd_lastfile * 2) i /= 2; - MALLOC(newfdp->fd_ofiles, struct file **, i * OFILESIZE, - M_FILEDESC, M_WAITOK); + newfdp->fd_ofiles = malloc(i * OFILESIZE, M_FILEDESC, M_WAITOK); newfdp->fd_ofileflags = (char *) &newfdp->fd_ofiles[i]; } if (NDHISLOTS(i) <= NDHISLOTS(NDFILE)) { @@ -875,9 +871,9 @@ fdcopy(p) newfdp->fd_lomap = ((struct filedesc0 *) newfdp)->fd_dlomap; } else { - MALLOC(newfdp->fd_himap, u_int *, NDHISLOTS(i) * sizeof(u_int), + newfdp->fd_himap = malloc(NDHISLOTS(i) * sizeof(u_int), M_FILEDESC, M_WAITOK); - MALLOC(newfdp->fd_lomap, u_int *, NDLOSLOTS(i) * sizeof(u_int), + newfdp->fd_lomap = malloc(NDLOSLOTS(i) * sizeof(u_int), M_FILEDESC, M_WAITOK); } newfdp->fd_nfiles = i; @@ -924,10 +920,10 @@ fdfree(p) } p->p_fd = NULL; if (fdp->fd_nfiles > NDFILE) - FREE(fdp->fd_ofiles, M_FILEDESC); + free(fdp->fd_ofiles, M_FILEDESC); if (NDHISLOTS(fdp->fd_nfiles) > NDHISLOTS(NDFILE)) { - FREE(fdp->fd_himap, M_FILEDESC); - FREE(fdp->fd_lomap, M_FILEDESC); + free(fdp->fd_himap, M_FILEDESC); + free(fdp->fd_lomap, M_FILEDESC); } vrele(fdp->fd_cdir); if (fdp->fd_rdir) diff --git a/sys/kern/kern_ktrace.c b/sys/kern/kern_ktrace.c index 699fe89a58a..1226550a488 100644 --- a/sys/kern/kern_ktrace.c +++ b/sys/kern/kern_ktrace.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_ktrace.c,v 1.20 2000/04/29 17:46:28 millert Exp $ */ +/* $OpenBSD: kern_ktrace.c,v 1.21 2000/09/27 16:13:46 mickey Exp $ */ /* $NetBSD: kern_ktrace.c,v 1.23 1996/02/09 18:59:36 christos Exp $ */ /* @@ -112,7 +112,7 @@ ktrsyscall(vp, code, argsize, args) p->p_traceflag |= KTRFAC_ACTIVE; ktrinitheader(&kth, p, KTR_SYSCALL); - MALLOC(ktp, struct ktr_syscall *, len, M_TEMP, M_WAITOK); + ktp = malloc(len, M_TEMP, M_WAITOK); ktp->ktr_code = code; ktp->ktr_argsize = argsize; argp = (register_t *)((char *)ktp + sizeof(struct ktr_syscall)); @@ -121,7 +121,7 @@ ktrsyscall(vp, code, argsize, args) kth.ktr_buf = (caddr_t)ktp; kth.ktr_len = len; ktrwrite(vp, &kth); - FREE(ktp, M_TEMP); + free(ktp, M_TEMP); p->p_traceflag &= ~KTRFAC_ACTIVE; } @@ -206,7 +206,7 @@ ktrgenio(vp, fd, rw, iov, len, error) buflen = min(PAGE_SIZE, len + sizeof(struct ktr_genio)); ktrinitheader(&kth, p, KTR_GENIO); - MALLOC(ktp, struct ktr_genio *, buflen, M_TEMP, M_WAITOK); + ktp = malloc(buflen, M_TEMP, M_WAITOK); ktp->ktr_fd = fd; ktp->ktr_rw = rw; @@ -243,7 +243,7 @@ ktrgenio(vp, fd, rw, iov, len, error) resid -= count; } - FREE(ktp, M_TEMP); + free(ktp, M_TEMP); p->p_traceflag &= ~KTRFAC_ACTIVE; } diff --git a/sys/kern/sys_generic.c b/sys/kern/sys_generic.c index 3c53a9b7a85..593bd2e42b4 100644 --- a/sys/kern/sys_generic.c +++ b/sys/kern/sys_generic.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sys_generic.c,v 1.26 2000/07/07 14:33:20 art Exp $ */ +/* $OpenBSD: sys_generic.c,v 1.27 2000/09/27 16:13:46 mickey Exp $ */ /* $NetBSD: sys_generic.c,v 1.24 1996/03/29 00:25:32 cgd Exp $ */ /* @@ -225,8 +225,7 @@ dofilereadv(p, fd, fp, iovp, iovcnt, offset, retval) error = EINVAL; goto out; } - MALLOC(iov, struct iovec *, iovlen, M_IOV, M_WAITOK); - needfree = iov; + iov = needfree = malloc(iovlen, M_IOV, M_WAITOK); } else if ((u_int)iovcnt > 0) { iov = aiov; needfree = NULL; @@ -262,7 +261,7 @@ dofilereadv(p, fd, fp, iovp, iovcnt, offset, 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); bcopy((caddr_t)auio.uio_iov, (caddr_t)ktriov, iovlen); } #endif @@ -278,13 +277,13 @@ dofilereadv(p, fd, fp, iovp, iovcnt, offset, retval) if (error == 0) ktrgenio(p->p_tracep, 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: #if notyet FILE_UNUSE(fp, p); @@ -450,8 +449,7 @@ dofilewritev(p, fd, fp, iovp, iovcnt, offset, retval) if ((u_int)iovcnt > UIO_SMALLIOV) { if ((u_int)iovcnt > IOV_MAX) return (EINVAL); - MALLOC(iov, struct iovec *, iovlen, M_IOV, M_WAITOK); - needfree = iov; + iov = needfree = malloc(iovlen, M_IOV, M_WAITOK); } else if ((u_int)iovcnt > 0) { iov = aiov; needfree = NULL; @@ -487,7 +485,7 @@ dofilewritev(p, fd, fp, iovp, iovcnt, offset, 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); bcopy((caddr_t)auio.uio_iov, (caddr_t)ktriov, iovlen); } #endif @@ -506,13 +504,13 @@ dofilewritev(p, fd, fp, iovp, iovcnt, offset, retval) if (error == 0) ktrgenio(p->p_tracep, 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: #if notyet FILE_UNUSE(fp, p); diff --git a/sys/kern/tty_subr.c b/sys/kern/tty_subr.c index 2bb0490c46f..e5ce35f924a 100644 --- a/sys/kern/tty_subr.c +++ b/sys/kern/tty_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty_subr.c,v 1.8 2000/08/04 16:39:47 deraadt Exp $ */ +/* $OpenBSD: tty_subr.c,v 1.9 2000/09/27 16:13:46 mickey Exp $ */ /* $NetBSD: tty_subr.c,v 1.13 1996/02/09 19:00:43 christos Exp $ */ /* @@ -93,15 +93,15 @@ clalloc(clp, size, quot) 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); bzero(clp->c_cs, 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); clp->c_cs = NULL; return (-1); } @@ -122,11 +122,11 @@ clfree(clp) { if (clp->c_cs) { bzero(clp->c_cs, clp->c_cn); - FREE(clp->c_cs, M_TTYS); + free(clp->c_cs, M_TTYS); } if (clp->c_cq) { bzero(clp->c_cq, QMEM(clp->c_cn)); - FREE(clp->c_cq, M_TTYS); + free(clp->c_cq, M_TTYS); } clp->c_cs = clp->c_cq = (u_char *)0; } diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c index 4bd3f24da99..0beecbb5650 100644 --- a/sys/kern/uipc_syscalls.c +++ b/sys/kern/uipc_syscalls.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_syscalls.c,v 1.30 2000/01/17 18:16:48 deraadt Exp $ */ +/* $OpenBSD: uipc_syscalls.c,v 1.31 2000/09/27 16:13:46 mickey Exp $ */ /* $NetBSD: uipc_syscalls.c,v 1.19 1996/02/09 19:00:48 christos Exp $ */ /* @@ -390,8 +390,8 @@ sys_sendmsg(p, v, retval) if (msg.msg_iovlen <= 0 || msg.msg_iovlen > IOV_MAX) return (EMSGSIZE); if (msg.msg_iovlen > UIO_SMALLIOV) - 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 (msg.msg_iovlen && @@ -405,7 +405,7 @@ sys_sendmsg(p, v, retval) 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); } @@ -485,7 +485,7 @@ sendit(p, s, mp, flags, retsize) 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); bcopy((caddr_t)auio.uio_iov, (caddr_t)ktriov, iovlen); } #endif @@ -506,7 +506,7 @@ sendit(p, s, mp, flags, retsize) if (error == 0) ktrgenio(p->p_tracep, s, UIO_WRITE, ktriov, *retsize, error); - FREE(ktriov, M_TEMP); + free(ktriov, M_TEMP); } #endif bad: @@ -574,8 +574,8 @@ sys_recvmsg(p, v, retval) if (msg.msg_iovlen <= 0 || msg.msg_iovlen > IOV_MAX) return (EMSGSIZE); if (msg.msg_iovlen > UIO_SMALLIOV) - 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; #ifdef COMPAT_OLDSOCK @@ -596,7 +596,7 @@ sys_recvmsg(p, v, retval) } done: if (iov != aiov) - FREE(iov, M_IOV); + free(iov, M_IOV); return (error); } @@ -639,7 +639,7 @@ recvit(p, s, mp, namelenp, retsize) 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); bcopy((caddr_t)auio.uio_iov, (caddr_t)ktriov, iovlen); } #endif @@ -657,7 +657,7 @@ recvit(p, s, mp, namelenp, retsize) if (error == 0) ktrgenio(p->p_tracep, s, UIO_READ, ktriov, len - auio.uio_resid, error); - FREE(ktriov, M_TEMP); + free(ktriov, M_TEMP); } #endif if (error) diff --git a/sys/kern/vfs_init.c b/sys/kern/vfs_init.c index 50d4e45d670..c99dad50bcf 100644 --- a/sys/kern/vfs_init.c +++ b/sys/kern/vfs_init.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_init.c,v 1.9 1999/02/19 18:02:48 art Exp $ */ +/* $OpenBSD: vfs_init.c,v 1.10 2000/09/27 16:13:46 mickey Exp $ */ /* $NetBSD: vfs_init.c,v 1.6 1996/02/09 19:00:58 christos Exp $ */ /* @@ -122,8 +122,8 @@ vfs_opv_init_explicit(vfs_opv_desc) if (opv_desc_vector == NULL) { /* XXX - shouldn't be M_VNODE */ - MALLOC(opv_desc_vector, PFI *, - vfs_opv_numops * sizeof(PFI), M_VNODE, M_WAITOK); + opv_desc_vector = malloc(vfs_opv_numops * sizeof(PFI), + M_VNODE, M_WAITOK); bzero(opv_desc_vector, vfs_opv_numops * sizeof(PFI)); *(vfs_opv_desc->opv_desc_vector_p) = opv_desc_vector; DODEBUG(printf("vector at %p allocated\n", |