From 7902429e5d69bb6aa57c6f1411b163d3e037e0e1 Mon Sep 17 00:00:00 2001 From: Louis Burda Date: Wed, 29 Dec 2021 01:46:08 +0100 Subject: More refactoring, moved track manipulation into player Planning on creating a modular player_backend component --- src/tag.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'src/tag.c') diff --git a/src/tag.c b/src/tag.c index 452d099..9ffbfc0 100644 --- a/src/tag.c +++ b/src/tag.c @@ -1,4 +1,38 @@ #include "tag.h" #include "link.h" +#include "ref.h" +#include +struct tag * +tag_init(const char *path, const char *fname) +{ + struct tag *tag; + + tag = malloc(sizeof(struct tag)); + ASSERT(tag != NULL); + + tag->fname = strdup(fname); + ASSERT(tag->fname != NULL); + + tag->fpath = aprintf("%s/%s", path, fname); + ASSERT(tag->fpath != NULL); + + tag->name = sanitized(tag->fname); + ASSERT(tag->name != NULL); + + tag->link = LINK_EMPTY; + + tag->tracks = LIST_HEAD; + + return tag; +} + +void +tag_free(struct tag *tag) +{ + free(tag->fname); + free(tag->fpath); + free(tag->name); + refs_free(&tag->tracks); +} -- cgit v1.2.3-71-gd317