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/tcp.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/tcp.c')
-rw-r--r-- | libavformat/tcp.c | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/libavformat/tcp.c b/libavformat/tcp.c index fda34a368d..0d3aeaf48c 100644 --- a/libavformat/tcp.c +++ b/libavformat/tcp.c @@ -39,7 +39,7 @@ static int tcp_open(URLContext *h, const char *uri, int flags) { struct addrinfo hints, *ai, *cur_ai; int port, fd = -1; - TCPContext *s = NULL; + TCPContext *s = h->priv_data; int listen_socket = 0; const char *p; char buf[256]; @@ -135,12 +135,6 @@ static int tcp_open(URLContext *h, const char *uri, int flags) goto fail; } } - s = av_malloc(sizeof(TCPContext)); - if (!s) { - freeaddrinfo(ai); - return AVERROR(ENOMEM); - } - h->priv_data = s; h->is_streamed = 1; s->fd = fd; freeaddrinfo(ai); @@ -193,7 +187,6 @@ static int tcp_close(URLContext *h) { TCPContext *s = h->priv_data; closesocket(s->fd); - av_free(s); return 0; } @@ -210,4 +203,5 @@ URLProtocol ff_tcp_protocol = { .url_write = tcp_write, .url_close = tcp_close, .url_get_file_handle = tcp_get_file_handle, + .priv_data_size = sizeof(TCPContext), }; |