From 67c41033c189f1efccdc4e40a7916c2ad46e40a6 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 16 Dec 2009 17:27:52 +0100 Subject: cue_tag: merged code into cue_tag_merge() --- src/cue/cue_tag.c | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-) (limited to 'src/cue') diff --git a/src/cue/cue_tag.c b/src/cue/cue_tag.c index 15cf0015..70f7fc76 100644 --- a/src/cue/cue_tag.c +++ b/src/cue/cue_tag.c @@ -155,6 +155,22 @@ cue_tag_track(struct Cdtext *cdtext, struct Rem *rem) return tag; } +static struct tag * +cue_tag_merge(struct tag *a, struct tag *b) +{ + if (a != NULL && b != NULL) { + struct tag *merge_tag = tag_merge(a, b); + tag_free(a); + tag_free(b); + return merge_tag; + } else if (a != NULL) + return a; + else if (b != NULL) + return b; + else + return NULL; +} + struct tag * cue_tag_file(FILE *fp, unsigned tnum) { @@ -179,17 +195,7 @@ cue_tag_file(FILE *fp, unsigned tnum) cd_delete(cd); - if (cd_tag != NULL && track_tag != NULL) { - struct tag *merge_tag = tag_merge(cd_tag, track_tag); - tag_free(cd_tag); - tag_free(track_tag); - return merge_tag; - } else if (cd_tag != NULL) - return cd_tag; - else if (track_tag != NULL) - return track_tag; - else - return NULL; + return cue_tag_merge(cd_tag, track_tag); } struct tag * @@ -216,15 +222,5 @@ cue_tag_string(const char *str, unsigned tnum) cd_delete(cd); - if (cd_tag != NULL && track_tag != NULL) { - struct tag *merge_tag = tag_merge(cd_tag, track_tag); - tag_free(cd_tag); - tag_free(track_tag); - return merge_tag; - } else if (cd_tag != NULL) - return cd_tag; - else if (track_tag != NULL) - return track_tag; - else - return NULL; + return cue_tag_merge(cd_tag, track_tag); } -- cgit v1.2.3