milky-way-view: Prefer g_auto* macros

g_autofree will automatically free variables when they go out of
scope. g_autoptr will do the same, but using the appropriate freefunc
for the given type, e.g. GDateTime -> g_date_time_unref() or
GObject -> g_object_unref().

This automatic cleanup reduces the risk of memory leaks
and allows getting rid of some lines of code.
main
Evangelos Ribeiro Tzaras 2023-07-17 20:13:19 +02:00
rodzic 1ed1b769b8
commit a5ebb680f7
1 zmienionych plików z 4 dodań i 10 usunięć

Wyświetl plik

@ -134,11 +134,10 @@ picplanner_milky_way_set_disturbance (PicplannerMilkyway *milky_way,
double *coordinates_array_moon,
double *coordinates_array_milky_way)
{
char *char_label_disturbance_sun;
char *char_label_disturbance_moon;
char *char_label_no_disturbance;
char *char_label_possibly_no_disturbance;
g_autofree char *char_label_disturbance_sun = NULL;
g_autofree char *char_label_disturbance_moon = NULL;
g_autofree char *char_label_no_disturbance = NULL;
g_autofree char *char_label_possibly_no_disturbance = NULL;
char_label_disturbance_sun = picplanner_get_char_disturbance (date_time_noon,
-18, 360, -360,
@ -171,11 +170,6 @@ picplanner_milky_way_set_disturbance (PicplannerMilkyway *milky_way,
coordinates_array_milky_way);
gtk_label_set_text (GTK_LABEL (milky_way->label_possible_disturbance_sun), char_label_possibly_no_disturbance);
g_free (char_label_disturbance_sun);
g_free (char_label_disturbance_moon);
g_free (char_label_no_disturbance);
g_free (char_label_possibly_no_disturbance);
}