map

minimalist audio player
git clone https://porkepik.fr/map
Log | Files | Refs | README | LICENSE

commit 94c0a0fe90cf2bcf1c5c1be1e6d28ab0a8487644
parent 0e834f08246f5eecc77413b8889271043a128c34
Author: Thomas Philippe <dev@porkepik.fr>
Date:   Tue, 27 Aug 2019 19:09:51 +0200

simplify init_track

Diffstat:
Mmap.c | 8+++-----
1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/map.c b/map.c @@ -169,11 +169,10 @@ strend(const char *s, const char *t) static struct track * init_track(const char *curdir, const char *d_name) { - size_t temp_len, extension; + size_t extension; struct track *temp = malloc(sizeof(struct track)); - temp_len = strlen(curdir) + strlen(d_name); - temp->filename = malloc(temp_len + 1); + temp->filename = malloc(strlen(curdir) + strlen(d_name) + 1); if (!temp->filename) errx(1, "malloc failure"); strcpy(temp->filename, curdir); @@ -209,8 +208,7 @@ init_track(const char *curdir, const char *d_name) temp->format = "Vorbis"; } - temp_len = strlen(strrchr(temp->filename, '/') + 1); - temp->name = malloc(temp_len + 1); + temp->name = malloc(strlen(strrchr(temp->filename, '/'))); if (!temp->name) errx(1, "malloc failure"); strcpy(temp->name, strrchr(temp->filename, '/') + 1);