moon-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.
theme-selector
Evangelos Ribeiro Tzaras 2023-07-17 20:12:07 +02:00
rodzic 9ec83cc7e3
commit 1ed1b769b8
1 zmienionych plików z 1 dodań i 2 usunięć

Wyświetl plik

@ -139,13 +139,12 @@ picplanner_moon_set_illumination_intensity (PicplannerMoon *moon,
double illumination,
char *phase)
{
char *char_label_illumination;
g_autofree char *char_label_illumination = NULL;
char_label_illumination = g_strdup_printf ("%d%%", (int)round(illumination));
gtk_label_set_text (GTK_LABEL (moon->label_illumination), char_label_illumination);
gtk_label_set_text (GTK_LABEL (moon->label_phase), phase);
g_free (char_label_illumination);
}