All of lore.kernel.org
 help / color / mirror / Atom feed
* [lm-sensors] [PATCH 2/6] libsensors: Free bus statements sooner
@ 2009-02-11 16:43 Jean Delvare
  0 siblings, 0 replies; only message in thread
From: Jean Delvare @ 2009-02-11 16:43 UTC (permalink / raw)
  To: lm-sensors

Free bus statements from the configuration file as soon as we are done
with them.

---
 lib/init.c |   47 +++++++++++++++++++++++++++++------------------
 1 file changed, 29 insertions(+), 18 deletions(-)

--- lm-sensors.orig/lib/init.c	2009-02-10 22:00:25.000000000 +0100
+++ lm-sensors/lib/init.c	2009-02-10 22:01:46.000000000 +0100
@@ -61,18 +61,42 @@ static int sensors_parse(void)
 	return res;
 }
 
+static void free_bus(sensors_bus *bus)
+{
+	free(bus->adapter);
+}
+
+static void free_config_busses(void)
+{
+	int i;
+
+	for (i = 0; i < sensors_config_busses_count; i++)
+		free_bus(&sensors_config_busses[i]);
+	free(sensors_config_busses);
+	sensors_config_busses = NULL;
+	sensors_config_busses_count = sensors_config_busses_max = 0;
+}
+
 static int parse_config(FILE *input)
 {
 	int err;
 
-	if (sensors_scanner_init(input))
-		return -SENSORS_ERR_PARSE;
+	if (sensors_scanner_init(input)) {
+		err = -SENSORS_ERR_PARSE;
+		goto exit_cleanup;
+	}
 	err = sensors_parse();
 	sensors_scanner_exit();
-	if (err)
-		return -SENSORS_ERR_PARSE;
+	if (err) {
+		err = -SENSORS_ERR_PARSE;
+		goto exit_cleanup;
+	}
 
-	return 0;
+	err = sensors_substitute_busses();
+
+exit_cleanup:
+	free_config_busses();
+	return err;
 }
 
 int sensors_init(FILE *input)
@@ -107,8 +131,6 @@ int sensors_init(FILE *input)
 		}
 	}
 
-	if ((res = sensors_substitute_busses()))
-		goto exit_cleanup;
 	return 0;
 
 exit_cleanup:
@@ -134,11 +156,6 @@ static void free_chip_features(sensors_c
 	free(features->feature);
 }
 
-static void free_bus(sensors_bus *bus)
-{
-	free(bus->adapter);
-}
-
 static void free_label(sensors_label *label)
 {
 	free(label->name);
@@ -218,12 +235,6 @@ void sensors_cleanup(void)
 	sensors_proc_chips = NULL;
 	sensors_proc_chips_count = sensors_proc_chips_max = 0;
 
-	for (i = 0; i < sensors_config_busses_count; i++)
-		free_bus(&sensors_config_busses[i]);
-	free(sensors_config_busses);
-	sensors_config_busses = NULL;
-	sensors_config_busses_count = sensors_config_busses_max = 0;
-
 	for (i = 0; i < sensors_config_chips_count; i++)
 		free_chip(&sensors_config_chips[i]);
 	free(sensors_config_chips);

-- 
Jean Delvare

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-02-11 16:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-11 16:43 [lm-sensors] [PATCH 2/6] libsensors: Free bus statements sooner Jean Delvare

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.