Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/xlint lint: remove xmapalloc
details: https://anonhg.NetBSD.org/src/rev/7a1bc25b8fd4
branches: trunk
changeset: 984953:7a1bc25b8fd4
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Aug 01 17:59:47 2021 +0000
description:
lint: remove xmapalloc
Just trust the standard malloc to be smart enough.
No functional change.
diffstat:
usr.bin/xlint/common/externs.h | 3 +--
usr.bin/xlint/common/mem.c | 30 ++----------------------------
usr.bin/xlint/lint1/mem1.c | 7 +++----
usr.bin/xlint/lint2/mem2.c | 7 +++----
4 files changed, 9 insertions(+), 38 deletions(-)
diffs (121 lines):
diff -r 37602deea683 -r 7a1bc25b8fd4 usr.bin/xlint/common/externs.h
--- a/usr.bin/xlint/common/externs.h Sun Aug 01 16:29:28 2021 +0000
+++ b/usr.bin/xlint/common/externs.h Sun Aug 01 17:59:47 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: externs.h,v 1.14 2021/01/16 02:40:02 rillig Exp $ */
+/* $NetBSD: externs.h,v 1.15 2021/08/01 17:59:47 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -58,7 +58,6 @@
extern void *xrealloc(void *, size_t);
extern char *xstrdup(const char *);
extern void nomem(void);
-extern void *xmapalloc(size_t);
extern void xasprintf(char **, const char *, ...) __printflike(2, 3);
/*
diff -r 37602deea683 -r 7a1bc25b8fd4 usr.bin/xlint/common/mem.c
--- a/usr.bin/xlint/common/mem.c Sun Aug 01 16:29:28 2021 +0000
+++ b/usr.bin/xlint/common/mem.c Sun Aug 01 17:59:47 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mem.c,v 1.12 2021/04/18 22:51:24 rillig Exp $ */
+/* $NetBSD: mem.c,v 1.13 2021/08/01 17:59:47 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: mem.c,v 1.12 2021/04/18 22:51:24 rillig Exp $");
+__RCSID("$NetBSD: mem.c,v 1.13 2021/08/01 17:59:47 rillig Exp $");
#endif
#include <sys/param.h>
@@ -111,29 +111,3 @@
if (e < 0)
nomem();
}
-
-#if defined(MAP_ANONYMOUS) && !defined(MAP_ANON)
-#define MAP_ANON MAP_ANONYMOUS
-#endif
-
-void *
-xmapalloc(size_t len)
-{
- static const int prot = PROT_READ | PROT_WRITE;
- static int fd = -1;
- void *p;
-#ifdef MAP_ANON
- static const int flags = MAP_ANON | MAP_PRIVATE;
-#else
- static const int flags = MAP_PRIVATE;
-
- if (fd == -1) {
- if ((fd = open("/dev/zero", O_RDWR)) == -1)
- err(1, "Cannot open `/dev/zero'");
- }
-#endif
- p = mmap(NULL, len, prot, flags, fd, (off_t)0);
- if (p == (void *)-1)
- err(1, "Cannot map memory for %lu bytes", (unsigned long)len);
- return p;
-}
diff -r 37602deea683 -r 7a1bc25b8fd4 usr.bin/xlint/lint1/mem1.c
--- a/usr.bin/xlint/lint1/mem1.c Sun Aug 01 16:29:28 2021 +0000
+++ b/usr.bin/xlint/lint1/mem1.c Sun Aug 01 17:59:47 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mem1.c,v 1.45 2021/07/04 09:13:59 rillig Exp $ */
+/* $NetBSD: mem1.c,v 1.46 2021/08/01 17:59:47 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: mem1.c,v 1.45 2021/07/04 09:13:59 rillig Exp $");
+__RCSID("$NetBSD: mem1.c,v 1.46 2021/08/01 17:59:47 rillig Exp $");
#endif
#include <sys/types.h>
@@ -214,8 +214,7 @@
{
memory_block *mb = xmalloc(sizeof(*mb));
- /* use mmap instead of malloc to avoid malloc's size overhead */
- mb->start = xmapalloc(mblklen);
+ mb->start = xmalloc(mblklen);
mb->size = mblklen;
return mb;
diff -r 37602deea683 -r 7a1bc25b8fd4 usr.bin/xlint/lint2/mem2.c
--- a/usr.bin/xlint/lint2/mem2.c Sun Aug 01 16:29:28 2021 +0000
+++ b/usr.bin/xlint/lint2/mem2.c Sun Aug 01 17:59:47 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mem2.c,v 1.11 2020/12/29 11:35:11 rillig Exp $ */
+/* $NetBSD: mem2.c,v 1.12 2021/08/01 17:59:47 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: mem2.c,v 1.11 2020/12/29 11:35:11 rillig Exp $");
+__RCSID("$NetBSD: mem2.c,v 1.12 2021/08/01 17:59:47 rillig Exp $");
#endif
#include <sys/param.h>
@@ -80,8 +80,7 @@
/* Align to at least 8 bytes. */
sz = (sz + 7) & ~7L;
if (nxtfree + sz > mblklen) {
- /* use mmap() instead of malloc() to avoid malloc overhead. */
- mbuf = xmapalloc(mblklen);
+ mbuf = xmalloc(mblklen);
(void)memset(mbuf, 0, mblklen);
nxtfree = 0;
}
Home |
Main Index |
Thread Index |
Old Index