player: simplify chapter display name code

The display name is always recomputed, so we can always toss the input
name.
This commit is contained in:
Ben Boeckel 2014-08-27 18:16:03 -04:00 committed by wm4
parent e023524481
commit 9780ff9642
1 changed files with 2 additions and 3 deletions

View File

@ -434,7 +434,7 @@ int get_current_chapter(struct MPContext *mpctx)
char *chapter_display_name(struct MPContext *mpctx, int chapter)
{
char *name = chapter_name(mpctx, chapter);
char *dname = name;
char *dname = NULL;
if (name) {
dname = talloc_asprintf(NULL, "(%d) %s", chapter + 1, name);
} else if (chapter < -1) {
@ -447,8 +447,7 @@ char *chapter_display_name(struct MPContext *mpctx, int chapter)
dname = talloc_asprintf(NULL, "(%d) of %d", chapter + 1,
chapter_count);
}
if (dname != name)
talloc_free(name);
talloc_free(name);
return dname;
}