]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
mp4: Clean up find_standard_meta().
authorAndre Noll <maan@tuebingen.mpg.de>
Sat, 14 Aug 2021 17:22:17 +0000 (19:22 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Mon, 30 May 2022 19:37:35 +0000 (21:37 +0200)
Use ARRAY_SIZE() instead of open-coding it, move the stdmetas array
into the function since it is only used there, and make it const.
Also replace 0 by NULL, since the function returns a pointer, and
remove the pointless comment.

Finally, move the function and the declaration of the stdmeta_entry
structure closer to its single user.

mp4.c

diff --git a/mp4.c b/mp4.c
index 1b935fa85bd177a7d7cabcf96e21987ebb98cd12..3167a132b1b6ca7a230d37df8c49f1c9abc9a12b 100644 (file)
--- a/mp4.c
+++ b/mp4.c
@@ -1203,29 +1203,6 @@ static unsigned membuffer_write_int32(struct membuffer *buf, uint32_t data)
        return membuffer_write(buf, temp, 4);
 }
 
-struct stdmeta_entry {
-       const char *atom;
-       const char *name;
-};
-
-struct stdmeta_entry stdmetas[] = {
-       {"\xA9" "nam", "title"},
-       {"\xA9" "ART", "artist"},
-       {"\xA9" "alb", "album"},
-       {"\xA9" "day", "date"},
-       {"\xA9" "cmt", "comment"},
-};
-
-static const char *find_standard_meta(const char *name)        //returns atom name if found, 0 if not
-{
-       unsigned n;
-       for (n = 0; n < sizeof (stdmetas) / sizeof (stdmetas[0]); n++) {
-               if (!strcasecmp(name, stdmetas[n].name))
-                       return stdmetas[n].atom;
-       }
-       return 0;
-}
-
 static void membuffer_write_std_tag(struct membuffer *buf, const char *name,
                const char *value)
 {
@@ -1277,6 +1254,27 @@ static void *membuffer_detach(struct membuffer *buf)
        return ret;
 }
 
+struct stdmeta_entry {
+       const char *atom;
+       const char *name;
+};
+
+static const char *find_standard_meta(const char *name)
+{
+       const struct stdmeta_entry stdmetas[] = {
+               {"\xA9" "nam", "title"},
+               {"\xA9" "ART", "artist"},
+               {"\xA9" "alb", "album"},
+               {"\xA9" "day", "date"},
+               {"\xA9" "cmt", "comment"},
+       };
+
+       for (unsigned n = 0; n < ARRAY_SIZE(stdmetas); n++)
+               if (!strcasecmp(name, stdmetas[n].name))
+                       return stdmetas[n].atom;
+       return NULL;
+}
+
 static uint32_t create_ilst(const struct mp4_metadata *meta, void **out_buffer,
                uint32_t * out_size)
 {