Skip to content

Commit

Permalink
Fix SimplyMenu to free title only if it is not the empty title (Addre…
Browse files Browse the repository at this point in the history
…sses #132)
  • Loading branch information
Meiguro committed Feb 14, 2016
1 parent 7b67001 commit 47dcc1d
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions src/simply/simply_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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, &section->node);
if (section->title && section->title != EMPTY_TITLE) {
free(section->title);
section->title = NULL;
}
prv_free_title(&section->title);
free(section);
}

Expand All @@ -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);
}

Expand Down

0 comments on commit 47dcc1d

Please sign in to comment.