code style
authorJean-Philippe Orsini <jeanfi@gmail.com>
Tue, 8 Nov 2011 01:46:42 +0000 (01:46 +0000)
committerJean-Philippe Orsini <jeanfi@gmail.com>
Tue, 8 Nov 2011 01:46:42 +0000 (01:46 +0000)
renaming rsensor_end to rsensor_cleanup
called rsensor_cleanup when quitting psensor

src/main.c
src/rsensor.c
src/rsensor.h

index 4daa4b7..1953e4b 100644 (file)
@@ -462,6 +462,9 @@ int main(int argc, char **argv)
 #ifdef HAVE_LIBATIADL
        amd_cleanup();
 #endif
+#ifdef HAVE_REMOTE_SUPPORT
+       rsensor_cleanup();
+#endif
 
        psensor_list_free(ui.sensors);
        ui.sensors = NULL;
index fadd02a..e6396e2 100644 (file)
@@ -108,7 +108,7 @@ void rsensor_init()
        curl = curl_easy_init();
 }
 
-void rsensor_end()
+void rsensor_cleanup()
 {
        curl_easy_cleanup(curl);
 }
@@ -144,9 +144,10 @@ static json_object *get_json_object(const char *url)
 struct psensor **get_remote_sensors(const char *server_url,
                                    int values_max_length)
 {
-       struct psensor **sensors;
+       struct psensor **sensors, *s;
        char *url;
        json_object *obj;
+       int i, n;
 
        sensors = NULL;
 
@@ -155,15 +156,14 @@ struct psensor **get_remote_sensors(const char *server_url,
        obj = get_json_object(url);
 
        if (obj && !is_error(obj)) {
-               int i;
-               int n = json_object_array_length(obj);
+               n = json_object_array_length(obj);
                sensors = malloc((n + 1) * sizeof(struct psensor *));
 
                for (i = 0; i < n; i++) {
-                       struct psensor *s = json_object_to_psensor
-                           (json_object_array_get_idx(obj, i),
-                            url,
-                            values_max_length);
+                       s = json_object_to_psensor
+                               (json_object_array_get_idx(obj, i),
+                                url,
+                                values_max_length);
                        sensors[i] = s;
                }
 
index a2deeb8..fa4fbb2 100644 (file)
@@ -27,5 +27,6 @@ struct psensor **get_remote_sensors(const char *server_url,
 void remote_psensor_list_update(struct psensor **sensors);
 
 void rsensor_init();
+void rsensor_cleanup();
 
 #endif