Remember to bzero string

Duplication was caused by malloc returning a
region of memory that already had data in it.
This commit is contained in:
stuart nelson 2016-09-18 16:17:49 +02:00
parent c02dcdeb35
commit 9f7822ccdc

View File

@ -82,7 +82,9 @@ getCPUTimes(int *ncpu, char **cputime) {
// string needs to hold (5*ncpu)(uint64_t + char)
// The char is the space between values.
*cputime = (char *) malloc((sizeof(uint64_t)+sizeof(char))*(5*(*ncpu)));
int cputime_size = (sizeof(uint64_t)+sizeof(char))*(5*(*ncpu));
*cputime = (char *) malloc(cputime_size);
bzero(*cputime, cputime_size);
uint64_t user, nice, sys, intr, idle;
user = nice = sys = intr = idle = 0;