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: clean up code for handling filenames
details: https://anonhg.NetBSD.org/src/rev/87c75225b49d
branches: trunk
changeset: 362448:87c75225b49d
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Feb 27 17:12:06 2022 +0000
description:
lint: clean up code for handling filenames
No functional change.
diffstat:
usr.bin/xlint/lint1/mem1.c | 19 ++++---------------
1 files changed, 4 insertions(+), 15 deletions(-)
diffs (64 lines):
diff -r 18bc642d7798 -r 87c75225b49d usr.bin/xlint/lint1/mem1.c
--- a/usr.bin/xlint/lint1/mem1.c Sun Feb 27 15:02:58 2022 +0000
+++ b/usr.bin/xlint/lint1/mem1.c Sun Feb 27 17:12:06 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mem1.c,v 1.60 2022/02/27 08:31:26 rillig Exp $ */
+/* $NetBSD: mem1.c,v 1.61 2022/02/27 17:12:06 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.60 2022/02/27 08:31:26 rillig Exp $");
+__RCSID("$NetBSD: mem1.c,v 1.61 2022/02/27 17:12:06 rillig Exp $");
#endif
#include <sys/param.h>
@@ -58,6 +58,7 @@
};
static struct filename *filenames; /* null-terminated array */
+static int next_filename_id;
/* Find the given filename, or return NULL. */
static const struct filename *
@@ -114,14 +115,6 @@
return buf;
}
-static int
-next_filename_id(void)
-{
- static int next_id = 0;
-
- return next_id++;
-}
-
/*
* Return a copy of the filename s with unlimited lifetime.
* If the filename is new, write it to the output file.
@@ -133,13 +126,9 @@
struct filename *fn;
char *name;
- if (s == NULL)
- return NULL;
-
if ((existing_fn = search_filename(s, slen)) != NULL)
return existing_fn->fn_name;
- /* Do not use strdup() because s is not NUL-terminated.*/
name = xmalloc(slen + 1);
(void)memcpy(name, s, slen);
name[slen] = '\0';
@@ -147,7 +136,7 @@
fn = xmalloc(sizeof(*fn));
fn->fn_name = name;
fn->fn_len = slen;
- fn->fn_id = next_filename_id();
+ fn->fn_id = next_filename_id++;
fn->fn_next = filenames;
filenames = fn;
Home |
Main Index |
Thread Index |
Old Index