diff options
author | Jean Delvare <khali@linux-fr.org> | 2007-06-28 14:39:34 +0000 |
---|---|---|
committer | Jean Delvare <khali@linux-fr.org> | 2007-06-28 14:39:34 +0000 |
commit | 92b5982180762edc5b9dacc333fb49a1422a5fbe (patch) | |
tree | 42ad243d2aca81662daaeb399f263b48c27cd8ff /lib/init.c | |
parent | 32b1b71245b9e0b4d3fc674b07a40f1b26c8908e (diff) | |
download | lm-sensors-git-92b5982180762edc5b9dacc333fb49a1422a5fbe.tar.gz |
With the new dynamic chip features enumeration code, the sensors_proc_chips
and sensors_chip_features_list arrays tend to track the same information.
So it's much more simple, and more efficient, to have a single array. I
decided to keep sensors_proc_chips, because it already has memory management
helpers. One nice side effect is that the arbitrary limit to the number of
supported chips is now gone. Another one is that some of the memory leaks
were fixed.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4510 7894878c-1315-0410-8ee3-d5d059ff63e0
Diffstat (limited to 'lib/init.c')
-rw-r--r-- | lib/init.c | 16 |
1 files changed, 14 insertions, 2 deletions
@@ -28,6 +28,7 @@ #include "scanner.h" static void free_chip_name(sensors_chip_name name); +static void free_chip_features(sensors_chip_feature *features); static void free_bus(sensors_bus bus); static void free_chip(sensors_chip chip); static void free_label(sensors_label label); @@ -59,8 +60,10 @@ void sensors_cleanup(void) sensors_scanner_exit(); - for (i = 0; i < sensors_proc_chips_count; i++) - free_chip_name(sensors_proc_chips[i]); + for (i = 0; i < sensors_proc_chips_count; i++) { + free_chip_name(sensors_proc_chips[i].chip); + free_chip_features(sensors_proc_chips[i].feature); + } free(sensors_proc_chips); sensors_proc_chips = NULL; sensors_proc_chips_count = sensors_proc_chips_max = 0; @@ -90,6 +93,15 @@ void free_chip_name(sensors_chip_name name) free(name.busname); } +void free_chip_features(sensors_chip_feature *features) +{ + int i; + + for (i = 0; features[i].data.name; i++) + free(features[i].data.name); + free(features); +} + void free_bus(sensors_bus bus) { free(bus.adapter); |