X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=spx_afh.c;h=bc2c6c42b7c087234bf4d97a3883d0bd2e4221c3;hp=e693c4150e03b7dae9b991c343ec7abbfe980db0;hb=017a63ecd7f2ff30233b50d455355400197bb660;hpb=92e4a0579a320372d2e94efc7c2a0d9f419e3ffe diff --git a/spx_afh.c b/spx_afh.c index e693c415..bc2c6c42 100644 --- a/spx_afh.c +++ b/spx_afh.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2011 Andre Noll + * Copyright (C) 2010-2012 Andre Noll * * Licensed under the GPL v2. For licencing details see COPYING. */ @@ -38,7 +38,6 @@ */ /** \file spx_afh.c Audio format handler for ogg/speex files. */ -#include #include #include #include @@ -57,31 +56,14 @@ struct private_spx_data { struct spx_header_info shi; }; - -static char *copy_comment(const char *src, int len) -{ - char *p = para_malloc(len + 1); - - if (len > 0) - memcpy(p, src, len); - p[len] = '\0'; - PARA_DEBUG_LOG("%s\n", p); - return p; -} - static bool copy_if_tag_type(const char *tag, int taglen, const char *type, char **p) { - int len = strlen(type); - - if (taglen <= len) - return false; - if (strncasecmp(tag, type, len)) - return false; - if (tag[len] != '=') + char *q = key_value_copy(tag, taglen, type); + if (!q) return false; free(*p); - *p = copy_comment(tag + len + 1, taglen - len - 1); + *p = q; return true; } @@ -100,7 +82,7 @@ static int spx_get_comments(unsigned char *comments, int length, c += 4; if (c + len > end) return -E_SPX_COMMENT; - tags->comment = copy_comment(c, len); + tags->comment = safe_strdup(c, len); c += len; if (c + 4 > end) @@ -129,7 +111,7 @@ static int spx_get_comments(unsigned char *comments, int length, continue; if (copy_if_tag_type(c, len, "comment", &tags->comment)) continue; - tag = copy_comment(c, len); + tag = safe_strdup(c, len); PARA_NOTICE_LOG("unrecognized comment: %s\n", tag); free(tag); }