Changeset 4205

Show
Ignore:
Timestamp:
10/13/06 14:43:43 (8 years ago)
Author:
khali
Message:

sensors: Handle option -c more efficiently.
We don't need to strdup() the file names, we can use them directly.
As a side effect, this fixes a memory leak which was happening if
option -c was specified more than once on the command line.

Location:
lm-sensors/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • lm-sensors/trunk/CHANGES

    r4204 r4205  
    1010  Program sensors: Add pc87247 support (fans only) 
    1111                   Hide error on missing f71805f fan 
     12                   Handle option -c more efficiently 
    1213  Program sensors-detect: Add SMSC DME1737 detection 
    1314                          Add EPoX EP1308 detection (Hans Edgington) 
  • lm-sensors/trunk/prog/sensors/main.c

    r4196 r4205  
    150150{ 
    151151  int c,res,i,error; 
    152   char *config_file_name = NULL; 
     152  const char *config_file_name = ETCDIR "/" DEFAULT_CONFIG_FILE_NAME; 
    153153 
    154154  struct option long_opts[] =  { 
     
    188188      exit(0); 
    189189    case 'c': 
    190       config_file_name = strdup(optarg); 
     190      config_file_name = optarg; 
    191191      break; 
    192192    case 's': 
     
    230230      } 
    231231 
    232  
    233   if (config_file_name == NULL) 
    234     config_file_name = strdup(ETCDIR "/" DEFAULT_CONFIG_FILE_NAME); 
    235232  open_config_file(config_file_name); 
    236  
    237233  if ((res = sensors_init(config_file))) { 
    238234    fprintf(stderr,"%s\n",sensors_strerror(res)); 
     
    244240    exit(1); 
    245241  } 
    246  
    247242  close_config_file(config_file_name); 
    248   free(config_file_name); 
    249243 
    250244  /* build the degrees string */