diff --git a/src/simply/simply_menu.c b/src/simply/simply_menu.c index 09276f00..a8a05d07 100644 --- a/src/simply/simply_menu.c +++ b/src/simply/simply_menu.c @@ -161,13 +161,17 @@ static SimplyMenuSection *prv_get_menu_section(SimplyMenu *self, int index) { (void*)(uintptr_t) index); } +static void prv_free_title(char **title) { + if (*title && *title != EMPTY_TITLE) { + free(*title); + *title = NULL; + } +} + static void prv_destroy_section(SimplyMenu *self, SimplyMenuSection *section) { if (!section) { return; } list1_remove(&self->menu_layer.sections, §ion->node); - if (section->title && section->title != EMPTY_TITLE) { - free(section->title); - section->title = NULL; - } + prv_free_title(§ion->title); free(section); } @@ -187,14 +191,8 @@ static SimplyMenuItem *prv_get_menu_item(SimplyMenu *self, int section, int inde static void prv_destroy_item(SimplyMenu *self, SimplyMenuItem *item) { if (!item) { return; } list1_remove(&self->menu_layer.items, &item->node); - if (item->title) { - free(item->title); - item->title = NULL; - } - if (item->subtitle) { - free(item->subtitle); - item->subtitle = NULL; - } + prv_free_title(&item->title); + prv_free_title(&item->subtitle); free(item); }