From 30666d1f0f431b581eeacc45735ff41d85d27c23 Mon Sep 17 00:00:00 2001 From: gad Date: Wed, 23 Jun 2004 23:48:09 +0000 Subject: Change "struct varent" to use the standard queue(8) macros, instead of using it's own version of the same basic algorithm. Submitted by: part by Cyrille Lefevre, part of it done by me --- bin/ps/ps.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'bin/ps/ps.c') diff --git a/bin/ps/ps.c b/bin/ps/ps.c index f4b0208..7d09131 100644 --- a/bin/ps/ps.c +++ b/bin/ps/ps.c @@ -98,7 +98,7 @@ int sumrusage; /* -S */ int termwidth; /* Width of the screen (0 == infinity). */ int totwidth; /* Calculated-width of requested variables. */ -struct varent *vhead; +struct velisthead varlist = STAILQ_HEAD_INITIALIZER(varlist); static int forceuread = DEF_UREAD; /* Do extra work to get u-area. */ static kvm_t *kd; @@ -600,9 +600,9 @@ main(int argc, char *argv[]) * For each process, call each variable output function. */ for (i = lineno = 0; i < nkept; i++) { - for (vent = vhead; vent; vent = vent->next) { + STAILQ_FOREACH(vent, &varlist, next_ve) { (vent->var->oproc)(&kinfo[i], vent); - if (vent->next != NULL) + if (STAILQ_NEXT(vent, next_ve) != NULL) (void)putchar(' '); } (void)putchar('\n'); @@ -886,7 +886,7 @@ find_varentry(VAR *v) { struct varent *vent; - for (vent = vhead; vent; vent = vent->next) { + STAILQ_FOREACH(vent, &varlist, next_ve) { if (strcmp(vent->var->name, v->name) == 0) return vent; } @@ -899,7 +899,7 @@ scanvars(void) struct varent *vent; VAR *v; - for (vent = vhead; vent; vent = vent->next) { + STAILQ_FOREACH(vent, &varlist, next_ve) { v = vent->var; if (v->flag & DSIZ) { v->dwidth = v->width; @@ -919,7 +919,7 @@ dynsizevars(KINFO *ki) VAR *v; int i; - for (vent = vhead; vent; vent = vent->next) { + STAILQ_FOREACH(vent, &varlist, next_ve) { v = vent->var; if (!(v->flag & DSIZ)) continue; @@ -938,7 +938,7 @@ sizevars(void) VAR *v; int i; - for (vent = vhead; vent; vent = vent->next) { + STAILQ_FOREACH(vent, &varlist, next_ve) { v = vent->var; i = strlen(vent->header); if (v->width < i) -- cgit v1.1