[vlc-commits] hds: drop macro

Tristan Matthews git at videolan.org
Fri Jul 25 09:31:22 CEST 2014


vlc | branch: master | Tristan Matthews <le.businessman at gmail.com> | Fri Jul 25 03:26:06 2014 -0400| [d4dc8ab09fbde58ecab4069fe1efb11e7e4aa576] | committer: Tristan Matthews

hds: drop macro

Fixes cid #1228697 from commit 160401294cbaa95b87bf0199c64590fef6b7fbc7

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

 modules/stream_filter/hds/hds.c |   46 +++++++++++++++++++++++++--------------
 1 file changed, 30 insertions(+), 16 deletions(-)

diff --git a/modules/stream_filter/hds/hds.c b/modules/stream_filter/hds/hds.c
index 55acc20..37ec06a 100644
--- a/modules/stream_filter/hds/hds.c
+++ b/modules/stream_filter/hds/hds.c
@@ -1009,9 +1009,6 @@ static void maintain_live_chunks(
     hds_stream->chunks_head = chunk;
 }
 
-#define SAFE_STRDUP( dest, src, ret )   \
-    if( !( (dest) = strdup( (src) ) ) ) \
-        return (ret)
 
 static void* live_thread( void* p )
 {
@@ -1032,7 +1029,8 @@ static void* live_thread( void* p )
     if( hds_stream->abst_url &&
         ( isFQUrl( hds_stream->abst_url ) ) )
     {
-        SAFE_STRDUP( abst_url, hds_stream->abst_url, NULL );
+        if( !( abst_url = strdup( hds_stream->abst_url ) ) )
+            return NULL;
     }
     else
     {
@@ -1152,9 +1150,11 @@ static int parse_Manifest( stream_t *s )
         {
         case XML_READER_STARTELEM:
             if( current_element_idx == 0 && element_stack[current_element_idx] == 0 ) {
-                SAFE_STRDUP( element_stack[current_element_idx], node, VLC_ENOMEM );
+                if( !( element_stack[current_element_idx] = strdup( node ) ) )
+                    return VLC_ENOMEM;
             } else {
-                SAFE_STRDUP( element_stack[++current_element_idx], node, VLC_ENOMEM );
+                if ( !( element_stack[++current_element_idx] = strdup( node ) ) )
+                    return VLC_ENOMEM;
             }
 
             break;
@@ -1190,15 +1190,18 @@ static int parse_Manifest( stream_t *s )
             {
                 if( !strcmp(attr_name, "streamId" ) )
                 {
-                    SAFE_STRDUP( medias[media_idx].stream_id, attr_value, VLC_ENOMEM );
+                    if( !( medias[media_idx].stream_id = strdup( attr_value ) ) )
+                        return VLC_ENOMEM;
                 }
                 if( !strcmp(attr_name, "url" ) )
                 {
-                    SAFE_STRDUP( medias[media_idx].media_url, attr_value, VLC_ENOMEM );
+                    if( !( medias[media_idx].media_url = strdup( attr_value ) ) )
+                        return VLC_ENOMEM;
                 }
                 if( !strcmp(attr_name, "bootstrapInfoId" ) )
                 {
-                    SAFE_STRDUP( medias[media_idx].bootstrap_id, attr_value, VLC_ENOMEM );
+                    if( !( medias[media_idx].bootstrap_id = strdup( attr_value ) ) )
+                        return VLC_ENOMEM;
                 }
             }
 
@@ -1211,15 +1214,18 @@ static int parse_Manifest( stream_t *s )
             {
                 if( !strcmp(attr_name, "url" ) )
                 {
-                    SAFE_STRDUP( bootstraps[bootstrap_idx].url, attr_value, VLC_ENOMEM );
+                    if( !( bootstraps[bootstrap_idx].url = strdup( attr_value ) ) )
+                        return VLC_ENOMEM;
                 }
                 if( !strcmp(attr_name, "id" ) )
                 {
-                    SAFE_STRDUP( bootstraps[bootstrap_idx].id, attr_value, VLC_ENOMEM );
+                    if( !( bootstraps[bootstrap_idx].id = strdup( attr_value ) ) )
+                       return VLC_ENOMEM;
                 }
                 if( !strcmp(attr_name, "profile" ) )
                 {
-                    SAFE_STRDUP( bootstraps[bootstrap_idx].profile, attr_value, VLC_ENOMEM );
+                    if( !( bootstraps[bootstrap_idx].profile = strdup( attr_value ) ) )
+                        return VLC_ENOMEM;
                 }
             }
         }
@@ -1250,7 +1256,8 @@ static int parse_Manifest( stream_t *s )
                 if( current_element &&
                     ! strcmp( element_stack[current_element_idx-1], "manifest" ) )
                 {
-                    SAFE_STRDUP( media_id, node, VLC_ENOMEM );
+                    if( !( media_id = strdup( node ) ) )
+                        return VLC_ENOMEM;
                 }
             }
         }
@@ -1285,7 +1292,11 @@ static int parse_Manifest( stream_t *s )
 
                 if( medias[i].media_url )
                 {
-                    SAFE_STRDUP( new_stream->url, medias[i].media_url, VLC_ENOMEM );
+                    if( !(new_stream->url = strdup( medias[i].media_url ) ) )
+                    {
+                        free(new_stream);
+                        return VLC_ENOMEM;
+                    }
                 }
 
                 if( ! sys->live )
@@ -1312,7 +1323,11 @@ static int parse_Manifest( stream_t *s )
                 }
                 else
                 {
-                    SAFE_STRDUP( new_stream->abst_url, bootstraps[j].url, VLC_ENOMEM );
+                    if( !(new_stream->abst_url = strdup( bootstraps[j].url ) ) )
+                    {
+                        free(new_stream);
+                        return VLC_ENOMEM;
+                    }
                 }
 
                 vlc_array_append( sys->hds_streams, new_stream );
@@ -1345,7 +1360,6 @@ static int parse_Manifest( stream_t *s )
     return VLC_SUCCESS;
 }
 
-#undef SAFE_STRDUP
 
 static void hds_free( hds_stream_t *p_stream )
 {



More information about the vlc-commits mailing list