40883a0b85
Some parts of our newlib implementation are the result of functions which have been propagated from module to module. In particular, those 'cleanup_stacks' routines are all similar & likely originated in the <pids> api. In that interface there was a need to free dynamically acquired memory before the result structure was reused to satisfy subsequent 'get', 'select' or 'reap' calls. This, in turn, led to a concept of 'dirty' stacks with the need to call one of two 'cleanup_stack' functions. None of the remaining interfaces deal with such memory yet they each had their own 'cleanup_stack' functions. Those functions were responsible for resetting each of the result unions to zero, excluding any 'noop' items. The bottom line is that for all interfaces, repetitive calls would require iterating through the stack(s) two separate times: once to 'cleanup' another to 'assign'. With this commit we will reduce iterations to just the 'assign' routine. A reset to zero will be accomplished in the 'extra' item set routine (which is the only one actually requiring any reset). All other items will be reinitialized automatically by a new current set value or upon reallocation when an items compliment changes. In the <pids> interface, any freeing of dynamic memory could have been accomplished by adding that 'freefunc' check to the 'assign' function. However, that requires an Item_table test with every item. Instead, we'll now satisfy such needs as the very first step in those set functions responsible for dynamically acquired memory. [ the <pids> api retains 2 'cleanup_stack' functions ] [ to accommodate stack(s) 'reset' & to serve 'unref' ] Lastly, all the 'itemize_stack' functions were tweaked by eliminating an unnecessary initialization of result unions. That objective was already accomplished by the calloc() in a 'stacks_alloc' function or the remaining 'cleanup_stack' routine found in the <pids> interface. Signed-off-by: Jim Warner <james.warner@comcast.net> |
||
---|---|---|
.. | ||
.gitignore | ||
COPYING | ||
devname.c | ||
devname.h | ||
diskstats.c | ||
diskstats.h | ||
escape.c | ||
escape.h | ||
libprocps.pc.in | ||
libprocps.sym | ||
meminfo.c | ||
meminfo.h | ||
namespace.c | ||
namespace.h | ||
numa.c | ||
numa.h | ||
pids.c | ||
pids.h | ||
procps-private.h | ||
procps.h | ||
pwcache.c | ||
pwcache.h | ||
readproc.c | ||
readproc.h | ||
slabinfo.c | ||
slabinfo.h | ||
stat.c | ||
stat.h | ||
sysinfo.c | ||
sysinfo.h | ||
test_namespace.c | ||
test_pids.c | ||
test_sysinfo.c | ||
test_uptime.c | ||
test_version.c | ||
uptime.c | ||
uptime.h | ||
version.c | ||
version.h | ||
vmstat.c | ||
vmstat.h | ||
wchan.c | ||
wchan.h | ||
xtra-procps-debug.h |