library: add chaining provisions to meminfo and vmstat

If a caller chooses to reduce the overhead of repeated
function calls, this commit provides for acquiring all
the desired information in just a single library call.

Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
Jim Warner
2015-06-28 00:00:00 -05:00
committed by Craig Small
parent 7a98cab187
commit a05084f381
5 changed files with 127 additions and 0 deletions

View File

@@ -157,3 +157,32 @@ PROCPS_EXPORT unsigned long procps_vmstat_get (
return 0;
}
PROCPS_EXPORT int procps_vmstat_get_chain (
struct procps_vmstat *info,
struct vmstat_result *item)
{
if (item == NULL)
return -EINVAL;
do {
switch (item->item) {
case PROCPS_VMSTAT_PGPGIN:
item->result = info->data.pgpgin;
break;
case PROCPS_VMSTAT_PGPGOUT:
item->result = info->data.pgpgout;
break;
case PROCPS_VMSTAT_PSWPIN:
item->result = info->data.pswpin;
break;
case PROCPS_VMSTAT_PSWPOUT:
item->result = info->data.pswpout;
break;
default:
return -EINVAL;
}
item = item->next;
} while (item);
return 0;
}