make(1): reduce pointer indirection for archives
This commit is contained in:
parent
673efe08f3
commit
aa3ed0e416
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: arch.c,v 1.179 2020/11/28 19:12:28 rillig Exp $ */
|
||||
/* $NetBSD: arch.c,v 1.180 2020/11/28 19:26:10 rillig Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
|
@ -125,12 +125,12 @@
|
|||
#include "config.h"
|
||||
|
||||
/* "@(#)arch.c 8.2 (Berkeley) 1/2/94" */
|
||||
MAKE_RCSID("$NetBSD: arch.c,v 1.179 2020/11/28 19:12:28 rillig Exp $");
|
||||
MAKE_RCSID("$NetBSD: arch.c,v 1.180 2020/11/28 19:26:10 rillig Exp $");
|
||||
|
||||
typedef struct List ArchList;
|
||||
typedef struct ListNode ArchListNode;
|
||||
|
||||
static ArchList *archives; /* The archives we've already examined */
|
||||
static ArchList archives; /* The archives we've already examined */
|
||||
|
||||
typedef struct Arch {
|
||||
char *name; /* Name of archive */
|
||||
|
@ -426,7 +426,7 @@ ArchStatMember(const char *archive, const char *member, Boolean addToCache)
|
|||
if (lastSlash != NULL)
|
||||
member = lastSlash + 1;
|
||||
|
||||
for (ln = archives->first; ln != NULL; ln = ln->next) {
|
||||
for (ln = archives.first; ln != NULL; ln = ln->next) {
|
||||
const Arch *a = ln->datum;
|
||||
if (strcmp(a->name, archive) == 0)
|
||||
break;
|
||||
|
@ -579,7 +579,7 @@ ArchStatMember(const char *archive, const char *member, Boolean addToCache)
|
|||
|
||||
fclose(arch);
|
||||
|
||||
Lst_Append(archives, ar);
|
||||
Lst_Append(&archives, ar);
|
||||
|
||||
/*
|
||||
* Now that the archive has been read and cached, we can look into
|
||||
|
@ -1063,7 +1063,7 @@ Arch_LibOODate(GNode *gn)
|
|||
void
|
||||
Arch_Init(void)
|
||||
{
|
||||
archives = Lst_New();
|
||||
Lst_Init(&archives);
|
||||
}
|
||||
|
||||
/* Clean up the archives module. */
|
||||
|
@ -1071,7 +1071,7 @@ void
|
|||
Arch_End(void)
|
||||
{
|
||||
#ifdef CLEANUP
|
||||
Lst_Destroy(archives, ArchFree);
|
||||
Lst_DoneCall(&archives, ArchFree);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: lst.c,v 1.95 2020/11/28 18:55:52 rillig Exp $ */
|
||||
/* $NetBSD: lst.c,v 1.96 2020/11/28 19:26:10 rillig Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
|
@ -34,7 +34,7 @@
|
|||
|
||||
#include "make.h"
|
||||
|
||||
MAKE_RCSID("$NetBSD: lst.c,v 1.95 2020/11/28 18:55:52 rillig Exp $");
|
||||
MAKE_RCSID("$NetBSD: lst.c,v 1.96 2020/11/28 19:26:10 rillig Exp $");
|
||||
|
||||
static ListNode *
|
||||
LstNodeNew(ListNode *prev, ListNode *next, void *datum)
|
||||
|
@ -68,6 +68,18 @@ Lst_Done(List *list)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
Lst_DoneCall(List *list, LstFreeProc freeProc)
|
||||
{
|
||||
ListNode *ln, *next;
|
||||
|
||||
for (ln = list->first; ln != NULL; ln = next) {
|
||||
next = ln->next;
|
||||
freeProc(ln->datum);
|
||||
free(ln);
|
||||
}
|
||||
}
|
||||
|
||||
/* Free a list and all its nodes. The node data are not freed though. */
|
||||
void
|
||||
Lst_Free(List *list)
|
||||
|
@ -82,14 +94,7 @@ Lst_Free(List *list)
|
|||
void
|
||||
Lst_Destroy(List *list, LstFreeProc freeProc)
|
||||
{
|
||||
ListNode *ln, *next;
|
||||
|
||||
for (ln = list->first; ln != NULL; ln = next) {
|
||||
next = ln->next;
|
||||
freeProc(ln->datum);
|
||||
free(ln);
|
||||
}
|
||||
|
||||
Lst_DoneCall(list, freeProc);
|
||||
free(list);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: lst.h,v 1.88 2020/11/28 18:55:52 rillig Exp $ */
|
||||
/* $NetBSD: lst.h,v 1.89 2020/11/28 19:26:10 rillig Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
|
||||
|
@ -111,6 +111,8 @@ typedef void LstFreeProc(void *);
|
|||
List *Lst_New(void);
|
||||
/* Free the list nodes, but not the list itself. */
|
||||
void Lst_Done(List *);
|
||||
/* Free the list nodes, freeing the node data using the given function. */
|
||||
void Lst_DoneCall(List *, LstFreeProc);
|
||||
/* Free the list, leaving the node data unmodified. */
|
||||
void Lst_Free(List *);
|
||||
/* Free the list, freeing the node data using the given function. */
|
||||
|
|
Loading…
Reference in New Issue