diff --git a/proc/pids.c b/proc/pids.c index d5758d38..0f221ff5 100644 --- a/proc/pids.c +++ b/proc/pids.c @@ -63,6 +63,7 @@ struct fetch_support { int n_inuse; // number of above pointers occupied int n_alloc_save; // last known results.stacks allocation struct pids_fetch results; // counts + stacks for return to caller + struct pids_counts counts; // actual counts pointed to by 'results' }; struct procps_pidsinfo { @@ -367,7 +368,6 @@ typedef int (*QSR_t)(const void *, const void *, void *); #define FF(e) (FRE_t)freNAME(e) #define QS(t) (QSR_t)srtNAME(t) - /* * Need it be said? * This table must be kept in the exact same order as @@ -1073,7 +1073,7 @@ static int stacks_fetch ( } cleanup_stacks_all(info); toggle_history(info); - memset(&info->fetch.results.counts, 0, sizeof(struct pids_counts)); + memset(&info->fetch.counts, 0, sizeof(struct pids_counts)); // iterate stuff -------------------------------------- n_inuse = 0; @@ -1085,7 +1085,7 @@ static int stacks_fetch ( return -1; memcpy(info->fetch.anchor + n_inuse, ext->stacks, sizeof(void *) * MEMORY_INCR); } - if (!proc_tally(info, &info->fetch.results.counts, &task)) + if (!proc_tally(info, &info->fetch.counts, &task)) return -1; assign_results(info, info->fetch.anchor[n_inuse++], &task); } @@ -1167,6 +1167,8 @@ PROCPS_EXPORT int procps_pids_new ( procps_uptime(&uptime_secs, NULL); p->boot_seconds = uptime_secs; + p->fetch.results.counts = &p->fetch.counts; + p->refcount = 1; *info = p; return 0; diff --git a/proc/pids.h b/proc/pids.h index a3285fc5..ebe72592 100644 --- a/proc/pids.h +++ b/proc/pids.h @@ -23,7 +23,6 @@ #ifndef _PROC_PIDS_H #define _PROC_PIDS_H -#include __BEGIN_DECLS enum pids_item { @@ -187,8 +186,8 @@ struct pids_counts { }; struct pids_fetch { + struct pids_counts *counts; struct pids_stack **stacks; - struct pids_counts counts; };