Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/xlint/lint1 lint: remove custom free list for memory...
details: https://anonhg.NetBSD.org/src/rev/acebc1ee2d8c
branches: trunk
changeset: 362044:acebc1ee2d8c
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Feb 27 06:55:13 2022 +0000
description:
lint: remove custom free list for memory blocks
Trust the system memory allocator to do its thing, including marking the
memory as fresh or freed. One less thing to worry about.
diffstat:
usr.bin/xlint/lint1/mem1.c | 37 ++++++++++++-------------------------
1 files changed, 12 insertions(+), 25 deletions(-)
diffs (81 lines):
diff -r 324b93e3b61f -r acebc1ee2d8c usr.bin/xlint/lint1/mem1.c
--- a/usr.bin/xlint/lint1/mem1.c Sun Feb 27 01:47:28 2022 +0000
+++ b/usr.bin/xlint/lint1/mem1.c Sun Feb 27 06:55:13 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mem1.c,v 1.57 2021/12/25 13:51:42 rillig Exp $ */
+/* $NetBSD: mem1.c,v 1.58 2022/02/27 06:55:13 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.57 2021/12/25 13:51:42 rillig Exp $");
+__RCSID("$NetBSD: mem1.c,v 1.58 2022/02/27 06:55:13 rillig Exp $");
#endif
#include <sys/param.h>
@@ -197,9 +197,6 @@
/* number of elements in *mblks */
static size_t nmblks;
-/* free list for memory blocks */
-static memory_block *frmblks;
-
/* length of new allocated memory blocks */
static size_t mblklen;
@@ -235,20 +232,16 @@
s = WORST_ALIGN(s);
if ((mb = *mbp) == NULL || mb->nfree < s) {
- if ((mb = frmblks) == NULL || mb->size < s) {
- if (s > mblklen) {
- t = mblklen;
- mblklen = s;
- }
- mb = xnewblk();
+ if (s > mblklen) {
+ t = mblklen;
+ mblklen = s;
+ }
+ mb = xnewblk();
#ifndef BLKDEBUG
- (void)memset(mb->start, 0, mb->size);
+ (void)memset(mb->start, 0, mb->size);
#endif
- if (t > 0)
- mblklen = t;
- } else {
- frmblks = mb->next;
- }
+ if (t > 0)
+ mblklen = t;
mb->first_free = mb->start;
mb->nfree = mb->size;
mb->next = *mbp;
@@ -263,10 +256,7 @@
return p;
}
-/*
- * Move all blocks from list *fmbp to free list. For each block, set all
- * used memory to zero.
- */
+/* Free all blocks from list *fmbp. */
static void
xfreeblk(memory_block **fmbp)
{
@@ -274,10 +264,7 @@
while ((mb = *fmbp) != NULL) {
*fmbp = mb->next;
- mb->next = frmblks;
- frmblks = mb;
- (void)memset(mb->start, INVALID_MEM_BYTE,
- mb->size - mb->nfree);
+ free(mb);
}
}
Home |
Main Index |
Thread Index |
Old Index