busybox/procps
Timo Teräs 7df1f1dda1 top: fix and merge code to parse /proc/meminfo
display_header() code to parse meminfo as is was buggy:
- uninitialized variables were used if meminfo was not as expected
- meminfo parsing failed on new kernels (3.14+) as new field 'MemAvailable'
  was introduced between MemFree and Buffers
- shared memory was handled only for ancient kernels (2.4.x and earlier)

as result Buffers and shared memory fields were shown with bogus values
on current kernels.

The new code does not try to parse the old style summary header, as the
separated fields are always present (it saves code size). Additionally,
both Shmem (2.6+) and MemShared (2.4 and earlier) fields are now parsed
and summed for shared memory usage; as only one of them exists depending
on kernel version.

display_topmem_header() parses also meminfo so this makes it use the
same code for code shrink.

function                                             old     new   delta
display_header                                         -     681    +681
display_topmem_process_list                          465     684    +219
parse_meminfo                                          -     189    +189
static.fields                                          -     106    +106
static.match                                         132       -    -132
.rodata                                           120254  120117    -137
display_topmem_header                                513       -    -513
display_process_list                                1705     667   -1038
------------------------------------------------------------------------------
(add/remove: 3/2 grow/shrink: 1/2 up/down: 1195/-1820)       Total: -625 bytes

Signed-off-by: Timo Teräs <timo.teras@iki.fi>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-07-27 21:49:27 +02:00
..
Config.src top: implement scrolling up/down (_very_ useful) 2012-09-21 13:04:37 +02:00
free.c *: work around sysinfo.h versus linux/*.h problems 2011-07-26 13:42:12 +02:00
fuser.c *: remove "Options:" string from help texts 2011-06-05 03:58:28 +02:00
iostat.c libbb: use a wrapper around sysconf(_SC_CLK_TCK) to save a few bytes 2014-06-22 14:01:13 +02:00
Kbuild.src nmeter: deprecate %NNNd specified, use -d MSEC instead 2010-12-13 15:17:22 +01:00
kill.c kill[all[5]]: code shrink 2013-12-16 17:45:44 +01:00
lsof.c lsof: correct check for symbolic link 2013-06-27 03:44:46 +02:00
mpstat.c libbb: use a wrapper around sysconf(_SC_CLK_TCK) to save a few bytes 2014-06-22 14:01:13 +02:00
nmeter.c Make smart_ulltoa return pointer to end (allows for code shink in callers) 2013-09-06 12:53:14 +02:00
pgrep.c Use unsigned printf/scanf conversion where more appropriate 2013-11-29 16:45:45 +01:00
pidof.c *: remove "Options:" string from help texts 2011-06-05 03:58:28 +02:00
pmap.c *: remove "Options:" string from help texts 2011-06-05 03:58:28 +02:00
powertop.c Make smart_ulltoa return pointer to end (allows for code shink in callers) 2013-09-06 12:53:14 +02:00
ps.c Make smart_ulltoa return pointer to end (allows for code shink in callers) 2013-09-06 12:53:14 +02:00
ps.posix
pstree.c pstree: fix theoretically unsafe code 2013-06-28 01:59:25 +02:00
pwdx.c pwdx: new applet 2011-03-12 18:13:15 +01:00
renice.c *: remove "Options:" string from help texts 2011-06-05 03:58:28 +02:00
smemcap.c rename archive.h to bb_archive.h. no code changes 2011-09-22 12:45:14 +02:00
sysctl.c sysctl: do not error out showing write-only data. Closes 6386 2014-02-24 17:28:43 +01:00
top.c top: fix and merge code to parse /proc/meminfo 2014-07-27 21:49:27 +02:00
uptime.c uptime: more compatible output 2011-08-10 13:00:04 +02:00
watch.c libbb: introduce and use strftime_[YYYYMMDD]HHMMSS() 2013-03-29 12:30:33 +01:00