static int Open( vlc_object_t *p_this )
{
device_probe_t *p_probe = (device_probe_t *)p_this;
- DBusError dbus_error;
- DBusConnection *p_connection;
- probe_sys_t *p_sys;
+ DBusError dbus_error;
+ DBusConnection *p_connection;
+ probe_sys_t *p_sys;
- p_probe->p_sys = p_sys = (probe_sys_t*)malloc( sizeof( probe_sys_t ) );
+ p_probe->p_sys = p_sys = malloc( sizeof( probe_sys_t ) );
p_probe->p_sys->i_devices = 0;
p_probe->p_sys->pp_devices = NULL;
if( !p_sys->p_ctx )
{
msg_Err( p_probe, "unable to create HAL context") ;
- free( p_probe->p_sys );
+ free( p_sys );
return VLC_EGENERIC;
}
p_connection = dbus_bus_get( DBUS_BUS_SYSTEM, &dbus_error );
if( dbus_error_is_set( &dbus_error ) )
{
msg_Err( p_probe, "unable to connect to DBUS: %s", dbus_error.message );
- dbus_error_free( &dbus_error );
- free( p_probe->p_sys );
- return VLC_EGENERIC;
+ goto error;
}
p_sys->p_connection = p_connection;
- libhal_ctx_set_dbus_connection( p_probe->p_sys->p_ctx, p_connection );
- if( !libhal_ctx_init( p_probe->p_sys->p_ctx, &dbus_error ) )
+ libhal_ctx_set_dbus_connection( p_sys->p_ctx, p_connection );
+ if( !libhal_ctx_init( p_sys->p_ctx, &dbus_error ) )
{
msg_Err( p_probe, "hal not available : %s", dbus_error.message );
dbus_connection_unref( p_connection );
- dbus_error_free( &dbus_error );
- free( p_sys );
- return VLC_EGENERIC;
+ goto error;
}
return VLC_SUCCESS;
+error:
+ dbus_error_free( &dbus_error );
+ libhal_ctx_free( p_sys->p_ctx );
+ free( p_sys );
+ return VLC_EGENERIC;
}
/*****************************************************************************
device_probe_t *p_probe = (device_probe_t *) p_this;
probe_sys_t *p_sys = p_probe->p_sys;
dbus_connection_unref( p_sys->p_connection );
+ libhal_ctx_free( p_sys->p_ctx );
free( p_sys );
}
#if 0