From 7e58050590c556643869a1cc57215026ff88b0db Mon Sep 17 00:00:00 2001 From: Martin Storsjö Date: Thu, 1 Dec 2011 11:44:21 +0200 Subject: proto: Use .priv_data_size to allocate the private context MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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ö --- libavformat/mmsh.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'libavformat/mmsh.c') diff --git a/libavformat/mmsh.c b/libavformat/mmsh.c index 3761016f81..a1ae894c6e 100644 --- a/libavformat/mmsh.c +++ b/libavformat/mmsh.c @@ -68,7 +68,6 @@ static int mmsh_close(URLContext *h) ffurl_close(mms->mms_hd); av_free(mms->streams); av_free(mms->asf_header); - av_freep(&h->priv_data); return 0; } @@ -217,12 +216,9 @@ static int mmsh_open(URLContext *h, const char *uri, int flags) char httpname[256], path[256], host[128], location[1024]; char *stream_selection = NULL; char headers[1024]; - MMSHContext *mmsh; + MMSHContext *mmsh = h->priv_data; MMSContext *mms; - mmsh = h->priv_data = av_mallocz(sizeof(MMSHContext)); - if (!h->priv_data) - return AVERROR(ENOMEM); mmsh->request_seq = h->is_streamed = 1; mms = &mmsh->mms; av_strlcpy(location, uri, sizeof(location)); @@ -367,4 +363,5 @@ URLProtocol ff_mmsh_protocol = { .url_open = mmsh_open, .url_read = mmsh_read, .url_close = mmsh_close, + .priv_data_size = sizeof(MMSHContext), }; -- cgit v1.2.3