decoder/mp4ff: rename and move local variable

Allocate the "tag" object after the file has been checked.  That
removes one tag_free() call in an error handler.
This commit is contained in:
Max Kellermann 2010-05-31 09:33:43 +02:00
parent be308c6657
commit 51c7577c8f
1 changed files with 5 additions and 6 deletions

View File

@ -367,7 +367,6 @@ mp4ff_tag_name_parse(const char *name)
static struct tag * static struct tag *
mp4_stream_tag(struct input_stream *is) mp4_stream_tag(struct input_stream *is)
{ {
struct tag *ret = NULL;
struct mp4ff_input_stream mis; struct mp4ff_input_stream mis;
int32_t track; int32_t track;
int32_t file_time; int32_t file_time;
@ -384,15 +383,15 @@ mp4_stream_tag(struct input_stream *is)
return NULL; return NULL;
} }
ret = tag_new();
file_time = mp4ff_get_track_duration_use_offsets(mp4fh, track); file_time = mp4ff_get_track_duration_use_offsets(mp4fh, track);
scale = mp4ff_time_scale(mp4fh, track); scale = mp4ff_time_scale(mp4fh, track);
if (scale < 0) { if (scale < 0) {
mp4ff_close(mp4fh); mp4ff_close(mp4fh);
tag_free(ret);
return NULL; return NULL;
} }
ret->time = ((float)file_time) / scale + 0.5;
struct tag *tag = tag_new();
tag->time = ((float)file_time) / scale + 0.5;
for (i = 0; i < mp4ff_meta_get_num_items(mp4fh); i++) { for (i = 0; i < mp4ff_meta_get_num_items(mp4fh); i++) {
char *item; char *item;
@ -402,7 +401,7 @@ mp4_stream_tag(struct input_stream *is)
enum tag_type type = mp4ff_tag_name_parse(item); enum tag_type type = mp4ff_tag_name_parse(item);
if (type != TAG_NUM_OF_ITEM_TYPES) if (type != TAG_NUM_OF_ITEM_TYPES)
tag_add_item(ret, type, value); tag_add_item(tag, type, value);
free(item); free(item);
free(value); free(value);
@ -410,7 +409,7 @@ mp4_stream_tag(struct input_stream *is)
mp4ff_close(mp4fh); mp4ff_close(mp4fh);
return ret; return tag;
} }
static const char *const mp4_suffixes[] = { "m4a", "mp4", NULL }; static const char *const mp4_suffixes[] = { "m4a", "mp4", NULL };