[PATCH] top: fix parsing of /proc/meminfo

Bernd Petrovitsch bernd at petrovitsch.priv.at
Sun Jul 20 10:23:25 UTC 2014


On Fre, 2014-07-18 at 22:07 +0300, Timo Teräs wrote:
> and do it in smaller code:
> 
> function                                             old     new   delta
> .rodata                                           120254  120205     -49
> display_process_list                                1705    1563    -142
> ------------------------------------------------------------------------------
> (add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-191)           Total: -191 bytes
> 
> Signed-off-by: Timo Teräs <timo.teras at iki.fi>
> ---
>  procps/top.c | 80 +++++++++++++++++++++++++++++++++---------------------------
>  1 file changed, 44 insertions(+), 36 deletions(-)
> 
> diff --git a/procps/top.c b/procps/top.c
> index 530f45f..e60dab6 100644
> --- a/procps/top.c
> +++ b/procps/top.c
> @@ -501,10 +501,27 @@ static void display_cpus(int scr_width, char *scrbuf, int *lines_rem_p)
>  
>  static unsigned long display_header(int scr_width, int *lines_rem_p)
>  {
> +	static const char *fields =

static const char fields[] =

> +		"MemTotal\0"
> +		"MemFree\0"
> +		"Shmem\0"
> +		"Buffers\0"
> +		"Cached\0"
> +		"Mem\0";

Does the above save space (as we do not require an extra pointer)?

	Bernd
-- 
"I dislike type abstraction if it has no real reason. And saving
on typing is not a good reason - if your typing speed is the main
issue when you're coding, you're doing something seriously wrong."
    - Linus Torvalds



More information about the busybox mailing list