reuse memory (for speed)
This commit is contained in:
parent
9673daccf4
commit
2efc9869f2
11
ps/display.c
11
ps/display.c
@ -333,7 +333,7 @@ not_root:
|
|||||||
|
|
||||||
/***** sorted or forest */
|
/***** sorted or forest */
|
||||||
static void fancy_spew(void){
|
static void fancy_spew(void){
|
||||||
proc_t *retbuf;
|
proc_t *retbuf = NULL;
|
||||||
PROCTAB* ptp;
|
PROCTAB* ptp;
|
||||||
int n = 0; /* number of processes & index into array */
|
int n = 0; /* number of processes & index into array */
|
||||||
ptp = openproc(PROC_FILLBUG);
|
ptp = openproc(PROC_FILLBUG);
|
||||||
@ -341,11 +341,14 @@ static void fancy_spew(void){
|
|||||||
fprintf(stderr, "Error: can not access /proc.\n");
|
fprintf(stderr, "Error: can not access /proc.\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
while((retbuf = ps_readproc(ptp,NULL))){
|
while((retbuf = ps_readproc(ptp,retbuf))){
|
||||||
fill_pcpu(retbuf);
|
fill_pcpu(retbuf);
|
||||||
if(want_this_proc(retbuf)) processes[n++] = retbuf;
|
if(want_this_proc(retbuf)){
|
||||||
else free(retbuf);
|
processes[n++] = retbuf;
|
||||||
|
retbuf = NULL; /* NULL asks ps_readproc to allocate */
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if(retbuf) free(retbuf);
|
||||||
closeproc(ptp);
|
closeproc(ptp);
|
||||||
if(!n) return; /* no processes */
|
if(!n) return; /* no processes */
|
||||||
if(forest_type) prep_forest_sort();
|
if(forest_type) prep_forest_sort();
|
||||||
|
Loading…
Reference in New Issue
Block a user