make(1): rename Lst_Init to Lst_New

For the other types such as HashTable and Buffer, the Init function does
not allocate the memory for the structure itself, it only fills it.
This commit is contained in:
rillig 2020-10-18 13:02:10 +00:00
parent fb73d14d90
commit 92688ee547
12 changed files with 84 additions and 84 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: arch.c,v 1.135 2020/10/18 12:36:43 rillig Exp $ */
/* $NetBSD: arch.c,v 1.136 2020/10/18 13:02:10 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -130,7 +130,7 @@
#include "config.h"
/* "@(#)arch.c 8.2 (Berkeley) 1/2/94" */
MAKE_RCSID("$NetBSD: arch.c,v 1.135 2020/10/18 12:36:43 rillig Exp $");
MAKE_RCSID("$NetBSD: arch.c,v 1.136 2020/10/18 13:02:10 rillig Exp $");
#ifdef TARGET_MACHINE
#undef MAKE_MACHINE
@ -357,7 +357,7 @@ Arch_ParseArchive(char **linePtr, GNodeList *nodeLst, GNode *ctxt)
*/
free(buf);
} else if (Dir_HasWildcards(memName)) {
StringList *members = Lst_Init();
StringList *members = Lst_New();
Dir_Expand(memName, dirSearchPath, members);
while (!Lst_IsEmpty(members)) {
@ -1126,7 +1126,7 @@ Arch_LibOODate(GNode *gn)
void
Arch_Init(void)
{
archives = Lst_Init();
archives = Lst_New();
}
/* Clean up the archives module. */

View File

@ -1,4 +1,4 @@
/* $NetBSD: dir.c,v 1.166 2020/10/18 12:47:43 rillig Exp $ */
/* $NetBSD: dir.c,v 1.167 2020/10/18 13:02:10 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@ -135,7 +135,7 @@
#include "job.h"
/* "@(#)dir.c 8.2 (Berkeley) 1/2/94" */
MAKE_RCSID("$NetBSD: dir.c,v 1.166 2020/10/18 12:47:43 rillig Exp $");
MAKE_RCSID("$NetBSD: dir.c,v 1.167 2020/10/18 13:02:10 rillig Exp $");
#define DIR_DEBUG0(text) DEBUG0(DIR, text)
#define DIR_DEBUG1(fmt, arg1) DEBUG1(DIR, fmt, arg1)
@ -227,7 +227,7 @@ typedef struct OpenDirs {
static void
OpenDirs_Init(OpenDirs *odirs)
{
odirs->list = Lst_Init();
odirs->list = Lst_New();
Hash_InitTable(&odirs->table);
}
@ -392,7 +392,7 @@ cached_lstat(const char *pathname, struct make_stat *st)
void
Dir_Init(void)
{
dirSearchPath = Lst_Init();
dirSearchPath = Lst_New();
OpenDirs_Init(&openDirs);
Hash_InitTable(&mtimes);
Hash_InitTable(&lmtimes);
@ -883,7 +883,7 @@ Dir_Expand(const char *word, SearchPath *path, StringList *expansions)
char *dp = &dirpath[strlen(dirpath) - 1];
if (*dp == '/')
*dp = '\0';
path = Lst_Init();
path = Lst_New();
(void)Dir_AddDir(path, dirpath);
DirExpandInt(cp + 1, path, expansions);
Lst_Free(path);

View File

@ -1,4 +1,4 @@
/* $NetBSD: job.c,v 1.264 2020/10/18 07:46:04 rillig Exp $ */
/* $NetBSD: job.c,v 1.265 2020/10/18 13:02:10 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@ -143,7 +143,7 @@
#include "trace.h"
/* "@(#)job.c 8.2 (Berkeley) 3/19/94" */
MAKE_RCSID("$NetBSD: job.c,v 1.264 2020/10/18 07:46:04 rillig Exp $");
MAKE_RCSID("$NetBSD: job.c,v 1.265 2020/10/18 13:02:10 rillig Exp $");
# define STATIC static
@ -1764,7 +1764,7 @@ JobRun(GNode *targ)
* Running these jobs in compat mode also guarantees that these
* jobs do not overlap with other unrelated jobs.
*/
List *lst = Lst_Init();
List *lst = Lst_New();
Lst_Append(lst, targ);
(void)Make_Run(lst);
Lst_Destroy(lst, NULL);

View File

@ -1,4 +1,4 @@
/* $NetBSD: lst.c,v 1.76 2020/10/18 08:58:29 rillig Exp $ */
/* $NetBSD: lst.c,v 1.77 2020/10/18 13:02:10 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -34,7 +34,7 @@
#include "make.h"
MAKE_RCSID("$NetBSD: lst.c,v 1.76 2020/10/18 08:58:29 rillig Exp $");
MAKE_RCSID("$NetBSD: lst.c,v 1.77 2020/10/18 13:02:10 rillig Exp $");
/* Allocate and initialize a list node.
*
@ -58,7 +58,7 @@ LstIsEmpty(List *list)
/* Create and initialize a new, empty list. */
List *
Lst_Init(void)
Lst_New(void)
{
List *list = bmake_malloc(sizeof *list);
@ -79,7 +79,7 @@ Lst_Copy(List *list, LstCopyProc copyProc)
List *newList;
ListNode *node;
newList = Lst_Init();
newList = Lst_New();
for (node = list->first; node != NULL; node = node->next) {
void *datum = copyProc != NULL ? copyProc(node->datum) : node->datum;

View File

@ -1,4 +1,4 @@
/* $NetBSD: lst.h,v 1.70 2020/10/18 08:58:29 rillig Exp $ */
/* $NetBSD: lst.h,v 1.71 2020/10/18 13:02:10 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@ -133,7 +133,7 @@ typedef int LstActionUntilProc(void *datum, void *args);
/* Create or destroy a list */
/* Create a new list. */
List *Lst_Init(void);
List *Lst_New(void);
/* Duplicate an existing list. */
List *Lst_Copy(List *, LstCopyProc);
/* Free the list, leaving the node data unmodified. */

View File

@ -1,4 +1,4 @@
/* $NetBSD: main.c,v 1.377 2020/10/18 12:47:43 rillig Exp $ */
/* $NetBSD: main.c,v 1.378 2020/10/18 13:02:10 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -118,7 +118,7 @@
#include "trace.h"
/* "@(#)main.c 8.3 (Berkeley) 3/19/94" */
MAKE_RCSID("$NetBSD: main.c,v 1.377 2020/10/18 12:47:43 rillig Exp $");
MAKE_RCSID("$NetBSD: main.c,v 1.378 2020/10/18 13:02:10 rillig Exp $");
#if defined(MAKE_NATIVE) && !defined(lint)
__COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
"The Regents of the University of California. "
@ -1128,11 +1128,11 @@ main(int argc, char **argv)
VAR_GLOBAL);
Var_Set(MAKE_DEPENDFILE, ".depend", VAR_GLOBAL);
create = Lst_Init();
makefiles = Lst_Init();
create = Lst_New();
makefiles = Lst_New();
printVars = 0;
debugVflag = FALSE;
variables = Lst_Init();
variables = Lst_New();
beSilent = FALSE; /* Print commands as executed */
ignoreErrors = FALSE; /* Pay attention to non-zero returns */
noExecute = FALSE; /* Execute all commands */
@ -1360,7 +1360,7 @@ main(int argc, char **argv)
if (!noBuiltins) {
StringListNode *ln;
sysMkPath = Lst_Init();
sysMkPath = Lst_New();
Dir_Expand(_PATH_DEFSYSMK,
Lst_IsEmpty(sysIncPath) ? defIncPath : sysIncPath,
sysMkPath);

View File

@ -1,4 +1,4 @@
/* $NetBSD: make.c,v 1.159 2020/10/18 11:09:08 rillig Exp $ */
/* $NetBSD: make.c,v 1.160 2020/10/18 13:02:10 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -107,7 +107,7 @@
#include "job.h"
/* "@(#)make.c 8.1 (Berkeley) 6/6/93" */
MAKE_RCSID("$NetBSD: make.c,v 1.159 2020/10/18 11:09:08 rillig Exp $");
MAKE_RCSID("$NetBSD: make.c,v 1.160 2020/10/18 13:02:10 rillig Exp $");
/* Sequence # to detect recursion. */
static unsigned int checked = 1;
@ -1232,7 +1232,7 @@ Make_ProcessWait(GNodeList *targs)
/* Start building with the 'dummy' .MAIN' node */
MakeBuildChild(pgn, NULL);
examine = Lst_Init();
examine = Lst_New();
Lst_Append(examine, pgn);
while (!Lst_IsEmpty(examine)) {
@ -1294,7 +1294,7 @@ Make_Run(GNodeList *targs)
int errors; /* Number of errors the Job module reports */
/* Start trying to make the current targets... */
toBeMade = Lst_Init();
toBeMade = Lst_New();
Make_ExpandUse(targs);
Make_ProcessWait(targs);

View File

@ -1,4 +1,4 @@
/* $NetBSD: meta.c,v 1.124 2020/10/18 11:54:43 rillig Exp $ */
/* $NetBSD: meta.c,v 1.125 2020/10/18 13:02:10 rillig Exp $ */
/*
* Implement 'meta' mode.
@ -625,7 +625,7 @@ meta_mode_init(const char *make_mode)
/*
* We consider ourselves master of all within ${.MAKE.META.BAILIWICK}
*/
metaBailiwick = Lst_Init();
metaBailiwick = Lst_New();
(void)Var_Subst("${.MAKE.META.BAILIWICK:O:u:tA}",
VAR_GLOBAL, VARE_WANTRES, &metaBailiwickStr);
/* TODO: handle errors */
@ -633,7 +633,7 @@ meta_mode_init(const char *make_mode)
/*
* We ignore any paths that start with ${.MAKE.META.IGNORE_PATHS}
*/
metaIgnorePaths = Lst_Init();
metaIgnorePaths = Lst_New();
Var_Append(MAKE_META_IGNORE_PATHS,
"/dev /etc /proc /tmp /var/run /var/tmp ${TMPDIR}", VAR_GLOBAL);
(void)Var_Subst("${" MAKE_META_IGNORE_PATHS ":O:u:tA}",
@ -1096,7 +1096,7 @@ meta_oodate(GNode *gn, Boolean oodate)
goto oodate_out;
dname = fname3;
missingFiles = Lst_Init();
missingFiles = Lst_New();
/*
* We need to check if the target is out-of-date. This includes

View File

@ -1,4 +1,4 @@
/* $NetBSD: parse.c,v 1.384 2020/10/18 08:58:29 rillig Exp $ */
/* $NetBSD: parse.c,v 1.385 2020/10/18 13:02:10 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -131,7 +131,7 @@
#include "pathnames.h"
/* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */
MAKE_RCSID("$NetBSD: parse.c,v 1.384 2020/10/18 08:58:29 rillig Exp $");
MAKE_RCSID("$NetBSD: parse.c,v 1.385 2020/10/18 13:02:10 rillig Exp $");
/* types and constants */
@ -1126,7 +1126,7 @@ ParseDoDependencyTargetSpecial(ParseSpecial *const inout_specType,
switch (*inout_specType) {
case ExPath:
if (*inout_paths == NULL) {
*inout_paths = Lst_Init();
*inout_paths = Lst_New();
}
Lst_Append(*inout_paths, dirSearchPath);
break;
@ -1189,7 +1189,7 @@ ParseDoDependencyTargetPath(const char *const line,
return FALSE;
} else {
if (*inout_paths == NULL) {
*inout_paths = Lst_Init();
*inout_paths = Lst_New();
}
Lst_Append(*inout_paths, path);
}
@ -1245,7 +1245,7 @@ ParseDoDependencyTargetMundane(char *const line,
* use Dir_Destroy in the destruction of the path as the
* Dir module could have added a directory to the path...
*/
SearchPath *emptyPath = Lst_Init();
SearchPath *emptyPath = Lst_New();
Dir_Expand(line, emptyPath, curTargs);
@ -1578,7 +1578,7 @@ ParseDoDependencySourcesMundane(char *line, char *cp,
}
if (*cp == '(') {
GNodeList *sources = Lst_Init();
GNodeList *sources = Lst_New();
if (!Arch_ParseArchive(&line, sources, VAR_CMD)) {
Parse_Error(PARSE_FATAL,
"Error in source archive spec \"%s\"", line);
@ -1654,7 +1654,7 @@ ParseDoDependency(char *line)
paths = NULL;
curTargs = Lst_Init();
curTargs = Lst_New();
/*
* First, grind through the targets.
@ -3023,7 +3023,7 @@ ParseDependency(char *line)
/* Need a fresh list for the target nodes */
if (targets != NULL)
Lst_Free(targets);
targets = Lst_Init();
targets = Lst_New();
ParseDoDependency(expanded_line);
free(expanded_line);
@ -3123,12 +3123,12 @@ void
Parse_Init(void)
{
mainNode = NULL;
parseIncPath = Lst_Init();
sysIncPath = Lst_Init();
defIncPath = Lst_Init();
parseIncPath = Lst_New();
sysIncPath = Lst_New();
defIncPath = Lst_New();
Vector_Init(&includes);
#ifdef CLEANUP
targCmds = Lst_Init();
targCmds = Lst_New();
#endif
}
@ -3167,7 +3167,7 @@ Parse_MainName(void)
{
GNodeList *mainList;
mainList = Lst_Init();
mainList = Lst_New();
if (mainNode == NULL) {
Punt("no target to make.");

View File

@ -1,4 +1,4 @@
/* $NetBSD: suff.c,v 1.179 2020/10/17 21:32:30 rillig Exp $ */
/* $NetBSD: suff.c,v 1.180 2020/10/18 13:02:10 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -129,7 +129,7 @@
#include "dir.h"
/* "@(#)suff.c 8.4 (Berkeley) 3/21/94" */
MAKE_RCSID("$NetBSD: suff.c,v 1.179 2020/10/17 21:32:30 rillig Exp $");
MAKE_RCSID("$NetBSD: suff.c,v 1.180 2020/10/18 13:02:10 rillig Exp $");
#define SUFF_DEBUG0(text) DEBUG0(SUFF, text)
#define SUFF_DEBUG1(fmt, arg1) DEBUG1(SUFF, fmt, arg1)
@ -417,10 +417,10 @@ SuffNew(const char *name)
s->name = bmake_strdup(name);
s->nameLen = strlen(s->name);
s->searchPath = Lst_Init();
s->children = Lst_Init();
s->parents = Lst_Init();
s->ref = Lst_Init();
s->searchPath = Lst_New();
s->children = Lst_New();
s->parents = Lst_New();
s->ref = Lst_New();
s->sNum = sNum++;
s->flags = 0;
s->refCount = 1;
@ -439,7 +439,7 @@ Suff_ClearSuffixes(void)
#ifdef CLEANUP
Lst_MoveAll(suffClean, sufflist);
#endif
sufflist = Lst_Init();
sufflist = Lst_New();
sNum = 0;
if (suffNull)
SuffFree(suffNull);
@ -570,8 +570,8 @@ Suff_AddTransform(const char *line)
gn = LstNode_Datum(ln);
Lst_Free(gn->commands);
Lst_Free(gn->children);
gn->commands = Lst_Init();
gn->children = Lst_Init();
gn->commands = Lst_New();
gn->children = Lst_New();
}
gn->type = OP_TRANSFORM;
@ -742,7 +742,7 @@ SuffScanTargets(void *targetp, void *gsp)
Targ_SetMain(NULL);
}
Lst_Free(target->children);
target->children = Lst_Init();
target->children = Lst_New();
target->type = OP_TRANSFORM;
/*
* link the two together in the proper relationship and order
@ -823,8 +823,8 @@ Suff_DoPaths(void)
SearchPath *inLibs; /* Cumulative .LIBS path */
inIncludes = Lst_Init();
inLibs = Lst_Init();
inIncludes = Lst_New();
inLibs = Lst_New();
Lst_Open(sufflist);
while ((ln = Lst_Next(sufflist)) != NULL) {
@ -934,7 +934,7 @@ SuffAddSrc(void *sp, void *lsp)
targ->children++;
Lst_Append(ls->l, s2);
#ifdef DEBUG_SRC
s2->cp = Lst_Init();
s2->cp = Lst_New();
Lst_Append(targ->cp, s2);
debug_printf("1 add %p %p to %p:", targ, s2, ls->l);
Lst_ForEach(ls->l, PrintAddr, NULL);
@ -952,7 +952,7 @@ SuffAddSrc(void *sp, void *lsp)
targ->children++;
Lst_Append(ls->l, s2);
#ifdef DEBUG_SRC
s2->cp = Lst_Init();
s2->cp = Lst_New();
Lst_Append(targ->cp, s2);
debug_printf("2 add %p %p to %p:", targ, s2, ls->l);
Lst_ForEach(ls->l, PrintAddr, NULL);
@ -1174,7 +1174,7 @@ SuffFindCmds(Src *targ, SrcList *slst)
ret->children = 0;
targ->children++;
#ifdef DEBUG_SRC
ret->cp = Lst_Init();
ret->cp = Lst_New();
debug_printf("3 add %p %p\n", targ, ret);
Lst_Append(targ->cp, ret);
#endif
@ -1225,7 +1225,7 @@ SuffExpandChildren(GNodeListNode *cln, GNode *pgn)
/* TODO: handle errors */
{
GNodeList *members = Lst_Init();
GNodeList *members = Lst_New();
if (cgn->type & OP_ARCHV) {
/*
@ -1359,7 +1359,7 @@ SuffExpandWildcards(GNodeListNode *cln, GNode *pgn)
/*
* Expand the word along the chosen path
*/
explist = Lst_Init();
explist = Lst_New();
Dir_Expand(cgn->name, Suff_FindPath(cgn), explist);
while (!Lst_IsEmpty(explist)) {
@ -1692,8 +1692,8 @@ SuffFindNormalDeps(GNode *gn, SrcList *slst)
* Begin at the beginning...
*/
ln = Lst_First(sufflist);
srcs = Lst_Init();
targs = Lst_Init();
srcs = Lst_New();
targs = Lst_New();
/*
* We're caught in a catch-22 here. On the one hand, we want to use any
@ -1738,7 +1738,7 @@ SuffFindNormalDeps(GNode *gn, SrcList *slst)
targ->parent = NULL;
targ->children = 0;
#ifdef DEBUG_SRC
targ->cp = Lst_Init();
targ->cp = Lst_New();
#endif
eopref = eoname - targ->suff->nameLen;
@ -1777,7 +1777,7 @@ SuffFindNormalDeps(GNode *gn, SrcList *slst)
targ->children = 0;
targ->pref = bmake_strdup(sopref);
#ifdef DEBUG_SRC
targ->cp = Lst_Init();
targ->cp = Lst_New();
#endif
/*
@ -2113,11 +2113,11 @@ void
Suff_Init(void)
{
#ifdef CLEANUP
suffClean = Lst_Init();
sufflist = Lst_Init();
suffClean = Lst_New();
sufflist = Lst_New();
#endif
srclist = Lst_Init();
transforms = Lst_Init();
srclist = Lst_New();
transforms = Lst_New();
/*
* Create null suffix for single-suffix rules (POSIX). The thing doesn't

View File

@ -1,4 +1,4 @@
/* $NetBSD: targ.c,v 1.115 2020/10/18 12:36:43 rillig Exp $ */
/* $NetBSD: targ.c,v 1.116 2020/10/18 13:02:10 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -121,7 +121,7 @@
#include "dir.h"
/* "@(#)targ.c 8.2 (Berkeley) 3/19/94" */
MAKE_RCSID("$NetBSD: targ.c,v 1.115 2020/10/18 12:36:43 rillig Exp $");
MAKE_RCSID("$NetBSD: targ.c,v 1.116 2020/10/18 13:02:10 rillig Exp $");
static GNodeList *allTargets; /* the list of all targets found so far */
#ifdef CLEANUP
@ -136,7 +136,7 @@ static void TargFreeGN(void *);
void
Targ_Init(void)
{
allTargets = Lst_Init();
allTargets = Lst_New();
Hash_InitTable(&targets);
}
@ -190,21 +190,21 @@ Targ_NewGN(const char *name)
gn->checked = 0;
gn->mtime = 0;
gn->cmgn = NULL;
gn->implicitParents = Lst_Init();
gn->cohorts = Lst_Init();
gn->parents = Lst_Init();
gn->children = Lst_Init();
gn->order_pred = Lst_Init();
gn->order_succ = Lst_Init();
gn->implicitParents = Lst_New();
gn->cohorts = Lst_New();
gn->parents = Lst_New();
gn->children = Lst_New();
gn->order_pred = Lst_New();
gn->order_succ = Lst_New();
Hash_InitTable(&gn->context);
gn->commands = Lst_Init();
gn->commands = Lst_New();
gn->suffix = NULL;
gn->fname = NULL;
gn->lineno = 0;
#ifdef CLEANUP
if (allGNs == NULL)
allGNs = Lst_Init();
allGNs = Lst_New();
Lst_Append(allGNs, gn);
#endif
@ -292,7 +292,7 @@ GNodeList *
Targ_FindList(StringList *names)
{
StringListNode *ln;
GNodeList *nodes = Lst_Init();
GNodeList *nodes = Lst_New();
for (ln = names->first; ln != NULL; ln = ln->next) {
const char *name = ln->datum;
GNode *gn = Targ_GetNode(name);

View File

@ -1,4 +1,4 @@
# $NetBSD: deptgt.mk,v 1.7 2020/09/25 23:39:51 rillig Exp $
# $NetBSD: deptgt.mk,v 1.8 2020/10/18 13:02:10 rillig Exp $
#
# Tests for special targets like .BEGIN or .SUFFIXES in dependency
# declarations.
@ -15,7 +15,7 @@
# ParseDoDependency at the beginning
# FinishDependencyGroup at "targets = NULL"
# Parse_File at "Lst_Free(targets)"
# Parse_File at "targets = Lst_Init()"
# Parse_File at "targets = Lst_New()"
# ParseLine_ShellCommand at "targets == NULL"
#
# Keywords: