]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/tcp.c
Replace PATCHWELCOME by relevant error codes.
[ffmpeg] / libavformat / tcp.c
index f882fc0deec10d764372883e4e334854985f7d49..1aeceb9e02ca6958123a8d0c3a67cb59dc76519a 100644 (file)
@@ -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),
 };