Fixed little bug in cache print and changed message when no cache level was found

This commit is contained in:
Dr-Noob
2018-03-29 23:35:42 +02:00
parent 978f283e1a
commit 720457f4ac
2 changed files with 26 additions and 12 deletions

34
udev.c
View File

@@ -115,19 +115,33 @@ char* getString_L1(struct cache* cach) {
}
char* getString_L2(struct cache* cach) {
//Max 4 digits and 2 for 'KB'
int size = (4+2+1);
char* string = malloc(sizeof(char)*size);
snprintf(string,size,"%dKB",cach->L2/1024);
return string;
if(cach->L2 == NO_CACHE) {
char* string = malloc(sizeof(char)*5);
snprintf(string,5,"None");
return string;
}
else {
//Max 4 digits and 2 for 'KB'
int size = (4+2+1);
char* string = malloc(sizeof(char)*size);
snprintf(string,size,"%dKB",cach->L2/1024);
return string;
}
}
char* getString_L3(struct cache* cach) {
//Max 4 digits and 2 for 'KB'
int size = (4+2+1);
char* string = malloc(sizeof(char)*size);
snprintf(string,size,"%dKB",cach->L3/1024);
return string;
if(cach->L3 == NO_CACHE) {
char* string = malloc(sizeof(char)*5);
snprintf(string,5,"None");
return string;
}
else {
//Max 4 digits and 2 for 'KB'
int size = (4+2+1);
char* string = malloc(sizeof(char)*size);
snprintf(string,size,"%dKB",cach->L3/1024);
return string;
}
}
char* getString_MaxFrequency(struct frequency* freq) {