From 77061a115db551088140aca8fbf1c9fc34628464 Mon Sep 17 00:00:00 2001 From: phk Date: Mon, 29 Jan 2001 09:45:51 +0000 Subject: Use instead of home-rolled list. Submitted by: "Jason Smethers" --- sbin/dump/dump.h | 7 ++----- sbin/dump/itime.c | 15 +++++++++------ sbin/dump/optr.c | 10 +++++----- 3 files changed, 16 insertions(+), 16 deletions(-) (limited to 'sbin') diff --git a/sbin/dump/dump.h b/sbin/dump/dump.h index 2c907a9..b41ffda 100644 --- a/sbin/dump/dump.h +++ b/sbin/dump/dump.h @@ -31,6 +31,8 @@ * SUCH DAMAGE. * * @(#)dump.h 8.2 (Berkeley) 4/28/95 + * + * $FreeBSD$ */ #define MAXINOPB (MAXBSIZE / sizeof(struct dinode)) @@ -166,11 +168,6 @@ struct dumpdates { char dd_level; time_t dd_ddate; }; -struct dumptime { - struct dumpdates dt_value; - struct dumptime *dt_next; -}; -struct dumptime *dthead; /* head of the list version */ int nddates; /* number of records (might be zero) */ int ddates_in; /* we have read the increment file */ struct dumpdates **ddatev; /* the arrayfied version */ diff --git a/sbin/dump/itime.c b/sbin/dump/itime.c index 6209dab..cd60c9e 100644 --- a/sbin/dump/itime.c +++ b/sbin/dump/itime.c @@ -40,6 +40,7 @@ static const char rcsid[] = #endif /* not lint */ #include +#include #include #ifdef sunos #include @@ -63,10 +64,14 @@ static const char rcsid[] = #include "dump.h" +struct dumptime { + struct dumpdates dt_value; + SLIST_ENTRY(dumptime) dt_list; +}; +SLIST_HEAD(dthead, dumptime) dthead = SLIST_HEAD_INITIALIZER(dthead); struct dumpdates **ddatev = 0; int nddates = 0; int ddates_in = 0; -struct dumptime *dthead = 0; static void dumprecout __P((FILE *, struct dumpdates *)); static int getrecord __P((FILE *, struct dumpdates *)); @@ -117,8 +122,7 @@ readdumptimes(df) if (getrecord(df, &(dtwalk->dt_value)) < 0) break; nddates++; - dtwalk->dt_next = dthead; - dthead = dtwalk; + SLIST_INSERT_HEAD(&dthead, dtwalk, dt_list); } ddates_in = 1; @@ -128,8 +132,8 @@ readdumptimes(df) */ ddatev = (struct dumpdates **) calloc((unsigned) (nddates + 1), sizeof (struct dumpdates *)); - dtwalk = dthead; - for (i = nddates - 1; i >= 0; i--, dtwalk = dtwalk->dt_next) + dtwalk = SLIST_FIRST(&dthead); + for (i = nddates - 1; i >= 0; i--, dtwalk = SLIST_NEXT(dtwalk, dt_list)) ddatev[i] = &dtwalk->dt_value; } @@ -184,7 +188,6 @@ putdumptime() free((char *)ddatev); ddatev = 0; nddates = 0; - dthead = 0; ddates_in = 0; readdumptimes(df); if (fseek(df, 0L, 0) < 0) diff --git a/sbin/dump/optr.c b/sbin/dump/optr.c index 57067a2..47c5792 100644 --- a/sbin/dump/optr.c +++ b/sbin/dump/optr.c @@ -40,6 +40,7 @@ static const char rcsid[] = #endif /* not lint */ #include +#include #include #include @@ -401,11 +402,11 @@ allocfsent(fs) } struct pfstab { - struct pfstab *pf_next; + SLIST_ENTRY(pfstab) pf_list; struct fstab *pf_fstab; }; -static struct pfstab *table; +static SLIST_HEAD(, pfstab) table; void getfstab() @@ -427,8 +428,7 @@ getfstab() if ((pf = (struct pfstab *)malloc(sizeof (*pf))) == NULL) quit("%s\n", strerror(errno)); pf->pf_fstab = fs; - pf->pf_next = table; - table = pf; + SLIST_INSERT_HEAD(&table, pf, pf_list); } (void) endfsent(); } @@ -447,7 +447,7 @@ fstabsearch(key) register struct fstab *fs; char *rn; - for (pf = table; pf != NULL; pf = pf->pf_next) { + SLIST_FOREACH(pf, &table, pf_list) { fs = pf->pf_fstab; if (strcmp(fs->fs_file, key) == 0 || strcmp(fs->fs_spec, key) == 0) -- cgit v1.1