add function to cleanup cpu model name
This commit is contained in:
		
							parent
							
								
									a1ffc9132a
								
							
						
					
					
						commit
						4df7191361
					
				@ -67,4 +67,6 @@ int sigar_mem_calc_ram(sigar_t *sigar, sigar_mem_t *mem);
 | 
			
		||||
double sigar_file_system_usage_calc_used(sigar_t *sigar,
 | 
			
		||||
                                         sigar_file_system_usage_t *fs);
 | 
			
		||||
 | 
			
		||||
void sigar_cpu_model_adjust(sigar_t *sigar, sigar_cpu_info_t *info);
 | 
			
		||||
 | 
			
		||||
#endif /* SIGAR_UTIL_H */
 | 
			
		||||
 | 
			
		||||
@ -258,6 +258,23 @@ double sigar_file_system_usage_calc_used(sigar_t *sigar,
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* common to win32 and linux */
 | 
			
		||||
void sigar_cpu_model_adjust(sigar_t *sigar, sigar_cpu_info_t *info)
 | 
			
		||||
{
 | 
			
		||||
    int len;
 | 
			
		||||
    char model[128], *ptr=model, *end;
 | 
			
		||||
 | 
			
		||||
    memcpy(model, info->model, sizeof(model));
 | 
			
		||||
 | 
			
		||||
    /* trim leading and trailing spaces */
 | 
			
		||||
    len = strlen(model);
 | 
			
		||||
    end = &model[len-1];
 | 
			
		||||
    while (*ptr == ' ') ++ptr;
 | 
			
		||||
    while (*end == ' ') *--end = '\0';
 | 
			
		||||
 | 
			
		||||
    strcpy(info->model, ptr);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#ifdef WIN32
 | 
			
		||||
#define vsnprintf _vsnprintf
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user