Fix bug: remove spaces between CPU name in certain processors

This commit is contained in:
Dr-Noob
2020-06-21 01:48:29 +02:00
parent 525cf1a76f
commit a1496278c3

View File

@@ -8,8 +8,8 @@ char* get_str_cpu_name() {
unsigned int ecx = 0; unsigned int ecx = 0;
unsigned int edx = 0; unsigned int edx = 0;
char name[64]; char *name = malloc(sizeof(char)*64);
memset(name,0,64); memset(name, 0, 64);
//First, check we can use extended //First, check we can use extended
eax = 0x80000000; eax = 0x80000000;
@@ -84,11 +84,14 @@ char* get_str_cpu_name() {
name[__COUNTER__] = '\0'; name[__COUNTER__] = '\0';
//Remove unused characters //Remove unused characters
int i = 0; char *str = name;
while(name[i] == ' ')i++; char *dest = name;
while (*str != '\0') {
char* name_withoutblank = malloc(sizeof(char)*64); while (*str == ' ' && *(str + 1) == ' ') str++;
strcpy(name_withoutblank,name+i); *dest++ = *str++;
return name_withoutblank; }
*dest = '\0';
return name;
} }