diff --git a/bin/ps/keyword.c b/bin/ps/keyword.c index 823018f12ba..40986550b92 100644 --- a/bin/ps/keyword.c +++ b/bin/ps/keyword.c @@ -305,10 +305,7 @@ parsefmt(const char *p, struct velisthead *const var_list, vent->header = hp; } vent->width = strlen(vent->header); - vent->var = malloc(sizeof(*vent->var)); - if (vent->var == NULL) - xo_errx(1, "malloc failed"); - memcpy(vent->var, v, sizeof(*vent->var)); + vent->var = v; STAILQ_INSERT_TAIL(var_list, vent, next_ve); } free(tempstr1); diff --git a/bin/ps/print.c b/bin/ps/print.c index d7d3fd1339d..a3f8f244648 100644 --- a/bin/ps/print.c +++ b/bin/ps/print.c @@ -73,7 +73,7 @@ static char sccsid[] = "@(#)print.c 8.6 (Berkeley) 4/16/94"; void printheader(void) { - VAR *v; + const VAR *v; struct varent *vent; STAILQ_FOREACH(vent, &varlist, next_ve) @@ -745,7 +745,7 @@ priorityr(KINFO *k, VARENT *ve __unused) * structures. */ static char * -printval(void *bp, VAR *v) +printval(void *bp, const VAR *v) { static char ofmt[32] = "%"; const char *fcp; @@ -796,7 +796,7 @@ printval(void *bp, VAR *v) char * kvar(KINFO *k, VARENT *ve) { - VAR *v; + const VAR *v; v = ve->var; return (printval((char *)((char *)k->ki_p + v->off), v)); @@ -805,7 +805,7 @@ kvar(KINFO *k, VARENT *ve) char * rvar(KINFO *k, VARENT *ve) { - VAR *v; + const VAR *v; v = ve->var; if (!k->ki_valid) diff --git a/bin/ps/ps.c b/bin/ps/ps.c index 44e6ecd3249..fe100170b7e 100644 --- a/bin/ps/ps.c +++ b/bin/ps/ps.c @@ -1217,7 +1217,7 @@ static void scanvars(void) { struct varent *vent; - VAR *v; + const VAR *v; STAILQ_FOREACH(vent, &varlist, next_ve) { v = vent->var; @@ -1232,7 +1232,7 @@ static void format_output(KINFO *ki) { struct varent *vent; - VAR *v; + const VAR *v; KINFO_STR *ks; char *str; u_int len; diff --git a/bin/ps/ps.h b/bin/ps/ps.h index 838aea33f3a..800e732262e 100644 --- a/bin/ps/ps.h +++ b/bin/ps/ps.h @@ -59,7 +59,7 @@ typedef struct kinfo { typedef struct varent { STAILQ_ENTRY(varent) next_ve; const char *header; - struct var *var; + const struct var *var; u_int width; } VARENT; STAILQ_HEAD(velisthead, varent);