X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=spx_afh.c;h=8f7d715cf20cc730d985845818c8dd49f4bde200;hp=6414f4c4ebba4fda67b7d64a32d570b50ba0436d;hb=23b121a85984baa9252f4b4c0b8c4f186e394bb7;hpb=b62e2796b85c7d7f3138fe729f4637853e0fafe0 diff --git a/spx_afh.c b/spx_afh.c index 6414f4c4..8f7d715c 100644 --- a/spx_afh.c +++ b/spx_afh.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2011 Andre Noll + * Copyright (C) 2010-2013 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); } @@ -139,7 +121,8 @@ static int spx_get_comments(unsigned char *comments, int length, static const char* speex_suffixes[] = {"spx", "speex", NULL}; static int spx_packet_callback(ogg_packet *packet, int packet_num, - struct afh_info *afhi, void *private_data) + __a_unused int serial, struct afh_info *afhi, + void *private_data) { struct private_spx_data *psd = private_data; int ret;