[vlc-devel] [PATCH 2/5] addons: vorepository: Simplify

Hugo Beauzée-Luyssen hugo at beauzee.fr
Thu Nov 2 14:35:28 CET 2017


---
 modules/misc/addons/vorepository.c | 28 +++++++---------------------
 1 file changed, 7 insertions(+), 21 deletions(-)

diff --git a/modules/misc/addons/vorepository.c b/modules/misc/addons/vorepository.c
index b014d49fef..c80172dd7c 100644
--- a/modules/misc/addons/vorepository.c
+++ b/modules/misc/addons/vorepository.c
@@ -345,29 +345,15 @@ static stream_t * vlc_stream_NewURL_ND( addons_finder_t *p_obj, const char *psz_
 
 static int Find( addons_finder_t *p_finder )
 {
-    bool b_done = false;
-
-    while ( !b_done )
-    {
-        char *psz_uri = NULL;
-
-        if ( ! asprintf( &psz_uri, ADDONS_REPO_SCHEMEHOST"/xml" ) ) return VLC_ENOMEM;
-        b_done = true;
-
-        stream_t *p_stream = vlc_stream_NewURL_ND( p_finder, psz_uri );
-        free( psz_uri );
-        if ( !p_stream ) return VLC_EGENERIC;
-
-        if ( ! ParseCategoriesInfo( p_finder, p_stream ) )
-        {
-            /* no more entries have been read: was last page or error */
-            b_done = true;
-        }
+    stream_t *p_stream = vlc_stream_NewURL_ND( p_finder,
+                                            ADDONS_REPO_SCHEMEHOST "/xml" );
+    if ( !p_stream )
+        return VLC_EGENERIC;
 
-        vlc_stream_Delete( p_stream );
-    }
+    int i_res = ParseCategoriesInfo( p_finder, p_stream );
+    vlc_stream_Delete( p_stream );
 
-    return VLC_SUCCESS;
+    return i_res > 0 ? VLC_SUCCESS : VLC_EGENERIC;
 }
 
 static int Retrieve( addons_finder_t *p_finder, addon_entry_t *p_entry )
-- 
2.11.0



More information about the vlc-devel mailing list