[vlc-commits] sap: remove useless string

Rémi Denis-Courmont git at videolan.org
Fri Jun 20 19:01:25 CEST 2014


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Fri Jun 20 18:52:44 2014 +0300| [c037e794f644dbc27551933368fac5923276853e] | committer: Rémi Denis-Courmont

sap: remove useless string

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c037e794f644dbc27551933368fac5923276853e
---

 src/stream_output/sap.c |   14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/src/stream_output/sap.c b/src/stream_output/sap.c
index 1d36ce0..cd8ade6 100644
--- a/src/stream_output/sap.c
+++ b/src/stream_output/sap.c
@@ -49,7 +49,6 @@ struct session_descriptor_t
     struct sockaddr_storage addr;
     socklen_t addrlen;
 
-    char *psz_sdp;
     bool b_ssm;
 };
 
@@ -210,7 +209,8 @@ static void *RunThread (void *self)
 /**
  * Add a SAP announce
  */
-static int SAP_Add (sap_handler_t *p_sap, session_descriptor_t *p_session)
+static int SAP_Add (sap_handler_t *p_sap, session_descriptor_t *p_session,
+                    const char *sdp)
 {
     int i;
     char psz_addr[NI_MAXNUMERICHOST];
@@ -347,7 +347,7 @@ static int SAP_Add (sap_handler_t *p_sap, session_descriptor_t *p_session)
     }
 
     /* XXX: Check for dupes */
-    length = headsize + strlen (p_session->psz_sdp);
+    length = headsize + strlen (sdp);
     p_sap_session = malloc (sizeof (*p_sap_session) + length + 1);
     if (p_sap_session == NULL)
     {
@@ -399,7 +399,7 @@ static int SAP_Add (sap_handler_t *p_sap, session_descriptor_t *p_session)
     headsize += 16;
 
     /* Build the final message */
-    strcpy( (char *)psz_head + headsize, p_session->psz_sdp);
+    strcpy((char *)psz_head + headsize, sdp);
 
     sap_addr->session_count++;
     vlc_cond_signal (&sap_addr->wait);
@@ -488,8 +488,6 @@ sout_AnnounceRegisterSDP( vlc_object_t *obj, const char *psz_sdp,
     if( !p_session )
         return NULL;
 
-    p_session->psz_sdp = strdup( psz_sdp );
-
     /* GRUIK. We should not convert back-and-forth from string to numbers */
     struct addrinfo *res;
     if (vlc_getaddrinfo (psz_dst, 0, NULL, &res) == 0)
@@ -516,7 +514,7 @@ sout_AnnounceRegisterSDP( vlc_object_t *obj, const char *psz_sdp,
         goto error;
 
     msg_Dbg (obj, "adding SAP session");
-    if (SAP_Add (p_sap, p_session))
+    if (SAP_Add (p_sap, p_session, psz_sdp))
     {
         vlc_mutex_lock (&sap_mutex);
         vlc_object_release ((vlc_object_t *)p_sap);
@@ -527,7 +525,6 @@ sout_AnnounceRegisterSDP( vlc_object_t *obj, const char *psz_sdp,
     return p_session;
 
 error:
-    free (p_session->psz_sdp);
     free (p_session);
     return NULL;
 }
@@ -552,7 +549,6 @@ int sout_AnnounceUnRegister( vlc_object_t *obj,
     vlc_object_release ((vlc_object_t *)p_sap);
     vlc_mutex_unlock (&sap_mutex);
 
-    free (p_session->psz_sdp);
     free (p_session);
 
     return 0;



More information about the vlc-commits mailing list