[vlc-devel] [PATCH 1/6] microdns: Split srv cleanup in a separate function
Hugo Beauzée-Luyssen
hugo at beauzee.fr
Fri Jun 26 17:11:07 CEST 2020
---
modules/services_discovery/microdns.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/modules/services_discovery/microdns.c b/modules/services_discovery/microdns.c
index ad0d2691f7..6899185b5b 100644
--- a/modules/services_discovery/microdns.c
+++ b/modules/services_discovery/microdns.c
@@ -269,6 +269,13 @@ items_clear( struct discovery_sys *p_sys )
vlc_array_clear( &p_sys->items );
}
+static void clear_srvs( struct srv *p_srvs, unsigned int i_nb_srv )
+{
+ for( unsigned int i = 0; i < i_nb_srv; ++i )
+ free( p_srvs[i].psz_device_name );
+ free( p_srvs );
+}
+
static int
parse_entries( const struct rr_entry *p_entries, bool b_renderer,
struct srv **pp_srvs, unsigned int *p_nb_srv,
@@ -356,9 +363,7 @@ parse_entries( const struct rr_entry *p_entries, bool b_renderer,
}
if( psz_ip == NULL || i_nb_srv == 0 )
{
- for( unsigned int i = 0; i < i_nb_srv; ++i )
- free( p_srvs[i].psz_device_name );
- free( p_srvs );
+ clear_srvs( p_srvs, i_nb_srv );
return VLC_EGENERIC;
}
@@ -416,9 +421,7 @@ new_entries_sd_cb( void *p_this, int i_status, const struct rr_entry *p_entries
items_add_input( p_sys, p_sd, psz_uri, p_srv->psz_device_name );
}
- for( unsigned int i = 0; i < i_nb_srv; ++i )
- free( p_srvs[i].psz_device_name );
- free( p_srvs );
+ clear_srvs( p_srvs, i_nb_srv );
}
@@ -529,9 +532,7 @@ new_entries_rd_cb( void *p_this, int i_status, const struct rr_entry *p_entries
free(psz_icon_uri);
}
- for( unsigned int i = 0; i < i_nb_srv; ++i )
- free( p_srvs[i].psz_device_name );
- free( p_srvs );
+ clear_srvs( p_srvs, i_nb_srv );
}
static bool
--
2.20.1
More information about the vlc-devel
mailing list