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/rtpproto.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/rtpproto.c')
-rw-r--r-- | libavformat/rtpproto.c | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/libavformat/rtpproto.c b/libavformat/rtpproto.c index 9707bdcec7..93cad3c8e6 100644 --- a/libavformat/rtpproto.c +++ b/libavformat/rtpproto.c @@ -136,7 +136,7 @@ static void build_udp_url(char *buf, int buf_size, static int rtp_open(URLContext *h, const char *uri, int flags) { - RTPContext *s; + RTPContext *s = h->priv_data; int rtp_port, rtcp_port, ttl, connect, local_rtp_port, local_rtcp_port, max_packet_size; @@ -145,11 +145,6 @@ static int rtp_open(URLContext *h, const char *uri, int flags) char path[1024]; const char *p; - s = av_mallocz(sizeof(RTPContext)); - if (!s) - return AVERROR(ENOMEM); - h->priv_data = s; - av_url_split(NULL, 0, NULL, 0, hostname, sizeof(hostname), &rtp_port, path, sizeof(path), uri); /* extract parameters */ @@ -213,7 +208,6 @@ static int rtp_open(URLContext *h, const char *uri, int flags) ffurl_close(s->rtp_hd); if (s->rtcp_hd) ffurl_close(s->rtcp_hd); - av_free(s); return AVERROR(EIO); } @@ -290,7 +284,6 @@ static int rtp_close(URLContext *h) ffurl_close(s->rtp_hd); ffurl_close(s->rtcp_hd); - av_free(s); return 0; } @@ -336,4 +329,5 @@ URLProtocol ff_rtp_protocol = { .url_write = rtp_write, .url_close = rtp_close, .url_get_file_handle = rtp_get_file_handle, + .priv_data_size = sizeof(RTPContext), }; |