Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F140641793
D29303.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D29303.diff
View Options
diff --git a/usr.bin/systat/pigs.c b/usr.bin/systat/pigs.c
--- a/usr.bin/systat/pigs.c
+++ b/usr.bin/systat/pigs.c
@@ -62,7 +62,7 @@
static struct p_times {
float pt_pctcpu;
struct kinfo_proc *pt_kp;
-} *pt;
+} *pt = NULL;
static int fscale;
static double lccpu;
@@ -90,7 +90,7 @@
const char *uname, *pname;
char pidname[30];
- if (pt == NULL)
+ if (nproc == 0)
return;
qsort(pt, nproc, sizeof (struct p_times), compar);
@@ -146,23 +146,20 @@
float ftime;
float *pctp;
struct kinfo_proc *kpp;
- static int lastnproc = 0;
+ static int maxnproc = 0;
if ((kpp = kvm_getprocs(kd, KERN_PROC_ALL, 0, &nproc)) == NULL) {
error("%s", kvm_geterr(kd));
- if (pt)
- free(pt);
+ nproc = 0;
return;
}
- if (nproc > lastnproc) {
- free(pt);
- if ((pt =
- malloc(nproc * sizeof(struct p_times))) == NULL) {
+ if (nproc > maxnproc) {
+ if ((pt = realloc(pt, nproc * sizeof(*pt))) == NULL) {
error("Out of memory");
die(0);
}
+ maxnproc = nproc;
}
- lastnproc = nproc;
/*
* calculate %cpu for each proc
*/
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Dec 27, 7:48 AM (5 h, 48 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
27300688
Default Alt Text
D29303.diff (1 KB)
Attached To
Mode
D29303: systat: Avoid incorrect reallocation in pigs.c
Attached
Detach File
Event Timeline
Log In to Comment