summaryrefslogtreecommitdiff
path: root/libavformat/udp.c
diff options
context:
space:
mode:
Diffstat (limited to 'libavformat/udp.c')
-rw-r--r--libavformat/udp.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/libavformat/udp.c b/libavformat/udp.c
index 178cef477a..529114a860 100644
--- a/libavformat/udp.c
+++ b/libavformat/udp.c
@@ -306,7 +306,7 @@ static int udp_open(URLContext *h, const char *uri, int flags)
{
char hostname[1024], localaddr[1024] = "";
int port, udp_fd = -1, tmp, bind_ret = -1;
- UDPContext *s = NULL;
+ UDPContext *s = h->priv_data;
int is_output;
const char *p;
char buf[256];
@@ -319,11 +319,6 @@ static int udp_open(URLContext *h, const char *uri, int flags)
is_output = !(flags & AVIO_FLAG_READ);
- s = av_mallocz(sizeof(UDPContext));
- if (!s)
- return AVERROR(ENOMEM);
-
- h->priv_data = s;
s->ttl = 16;
s->buffer_size = is_output ? UDP_TX_BUF_SIZE : UDP_MAX_PKT_SIZE;
@@ -440,7 +435,6 @@ static int udp_open(URLContext *h, const char *uri, int flags)
fail:
if (udp_fd >= 0)
closesocket(udp_fd);
- av_free(s);
return AVERROR(EIO);
}
@@ -486,7 +480,6 @@ static int udp_close(URLContext *h)
if (s->is_multicast && (h->flags & AVIO_FLAG_READ))
udp_leave_multicast_group(s->udp_fd, (struct sockaddr *)&s->dest_addr);
closesocket(s->udp_fd);
- av_free(s);
return 0;
}
@@ -497,4 +490,5 @@ URLProtocol ff_udp_protocol = {
.url_write = udp_write,
.url_close = udp_close,
.url_get_file_handle = udp_get_file_handle,
+ .priv_data_size = sizeof(UDPContext),
};