diff options
author | Martin Storsjö <martin@martin.st> | 2011-12-01 11:44:21 +0200 |
---|---|---|
committer | Martin Storsjö <martin@martin.st> | 2011-12-01 13:47:26 +0200 |
commit | 7e58050590c556643869a1cc57215026ff88b0db (patch) | |
tree | 13d62d154bc9e260991985dbb94b3ae04e034ea9 /libavformat/concat.c | |
parent | 9c6777bd9367e8680bb7ada9852f5760dc8a8594 (diff) | |
download | ffmpeg-7e58050590c556643869a1cc57215026ff88b0db.tar.gz |
proto: Use .priv_data_size to allocate the private context
This simplifies the open functions by avoiding one function
call that needs error checking, reducing the amount of
extra bulk code.
Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavformat/concat.c')
-rw-r--r-- | libavformat/concat.c | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/libavformat/concat.c b/libavformat/concat.c index 1501cbcba4..4bfa6288ba 100644 --- a/libavformat/concat.c +++ b/libavformat/concat.c @@ -50,7 +50,6 @@ static av_cold int concat_close(URLContext *h) err |= ffurl_close(nodes[i].uc); av_freep(&data->nodes); - av_freep(&h->priv_data); return err < 0 ? -1 : 0; } @@ -62,16 +61,11 @@ static av_cold int concat_open(URLContext *h, const char *uri, int flags) int64_t size; size_t len, i; URLContext *uc; - struct concat_data *data; + struct concat_data *data = h->priv_data; struct concat_nodes *nodes; av_strstart(uri, "concat:", &uri); - /* creating data */ - if (!(data = av_mallocz(sizeof(*data)))) - return AVERROR(ENOMEM); - h->priv_data = data; - for (i = 0, len = 1; uri[i]; i++) if (uri[i] == *AV_CAT_SEPARATOR) /* integer overflow */ @@ -81,7 +75,6 @@ static av_cold int concat_open(URLContext *h, const char *uri, int flags) } if (!(nodes = av_malloc(sizeof(*nodes) * len))) { - av_freep(&h->priv_data); return AVERROR(ENOMEM); } else data->nodes = nodes; @@ -196,4 +189,5 @@ URLProtocol ff_concat_protocol = { .url_read = concat_read, .url_seek = concat_seek, .url_close = concat_close, + .priv_data_size = sizeof(struct concat_data), }; |