mirror of https://code.videolan.org/videolan/vlc
Remove MALLOC_(VOID|ERR). (and use calloc instead of malloc+memset)
This commit is contained in:
parent
30b6a95067
commit
12879a4c3b
|
@ -149,22 +149,22 @@ static inline void access_InitFields( access_t *p_a )
|
|||
p_a->info.i_seekpoint = 0;
|
||||
}
|
||||
|
||||
#define ACCESS_SET_CALLBACKS( read, block, control, seek ) \
|
||||
p_access->pf_read = read; \
|
||||
p_access->pf_block = block; \
|
||||
p_access->pf_control = control; \
|
||||
p_access->pf_seek = seek; \
|
||||
#define ACCESS_SET_CALLBACKS( read, block, control, seek ) \
|
||||
p_access->pf_read = read; \
|
||||
p_access->pf_block = block; \
|
||||
p_access->pf_control = control; \
|
||||
p_access->pf_seek = seek;
|
||||
|
||||
#define STANDARD_READ_ACCESS_INIT \
|
||||
access_InitFields( p_access ); \
|
||||
ACCESS_SET_CALLBACKS( Read, NULL, Control, Seek ); \
|
||||
MALLOC_ERR( p_access->p_sys, access_sys_t ); \
|
||||
p_sys = p_access->p_sys; memset( p_sys, 0, sizeof( access_sys_t ) );
|
||||
#define STANDARD_READ_ACCESS_INIT \
|
||||
access_InitFields( p_access ); \
|
||||
ACCESS_SET_CALLBACKS( Read, NULL, Control, Seek ); \
|
||||
p_sys = p_access->p_sys = calloc( 1, sizeof( access_sys_t )); \
|
||||
if( !p_sys ) return VLC_ENOMEM;
|
||||
|
||||
#define STANDARD_BLOCK_ACCESS_INIT \
|
||||
access_InitFields( p_access ); \
|
||||
ACCESS_SET_CALLBACKS( NULL, Block, Control, Seek ); \
|
||||
MALLOC_ERR( p_access->p_sys, access_sys_t ); \
|
||||
p_sys = p_access->p_sys; memset( p_sys, 0, sizeof( access_sys_t ) );
|
||||
#define STANDARD_BLOCK_ACCESS_INIT \
|
||||
access_InitFields( p_access ); \
|
||||
ACCESS_SET_CALLBACKS( NULL, Block, Control, Seek ); \
|
||||
p_sys = p_access->p_sys = calloc( 1, sizeof( access_sys_t ) ); \
|
||||
if( !p_sys ) return VLC_ENOMEM;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -604,12 +604,8 @@ static inline uint8_t clip_uint8_vlc( int32_t a )
|
|||
}
|
||||
|
||||
/* Malloc with automatic error */
|
||||
#define MALLOC_VOID( var, type ) do { var = (type*)malloc( sizeof( type) ); \
|
||||
if( !var ) return; } while(0)
|
||||
#define MALLOC_NULL( var, type ) do { var = (type*)malloc( sizeof( type) ); \
|
||||
if( !var ) return NULL; } while(0)
|
||||
#define MALLOC_ERR( var, type ) do { var = (type*)malloc( sizeof( type) ); \
|
||||
if( !var ) return VLC_ENOMEM; } while(0)
|
||||
|
||||
#define FREENULL(a) do { free( a ); a = NULL; } while(0)
|
||||
|
||||
|
|
|
@ -192,7 +192,8 @@ VLC_EXPORT( void, demux_PacketizerDestroy, ( decoder_t *p_packetizer ) );
|
|||
#define DEMUX_INIT_COMMON() do { \
|
||||
p_demux->pf_control = Control; \
|
||||
p_demux->pf_demux = Demux; \
|
||||
MALLOC_ERR( p_demux->p_sys, demux_sys_t ); \
|
||||
p_demux->p_sys = malloc( sizeof( demux_sys_t ) ); \
|
||||
if( !p_demux->p_sys ) return VLC_ENOMEM;\
|
||||
memset( p_demux->p_sys, 0, sizeof( demux_sys_t ) ); } while(0)
|
||||
|
||||
#define STANDARD_DEMUX_INIT_MSG( msg ) do { \
|
||||
|
|
|
@ -109,7 +109,9 @@ static int Open( vlc_object_t *p_this )
|
|||
{
|
||||
intf_thread_t *p_intf = (intf_thread_t *)p_this;
|
||||
intf_sys_t *p_sys;
|
||||
MALLOC_ERR( p_sys, intf_sys_t );
|
||||
p_sys = malloc( sizeof( intf_sys_t ) );
|
||||
if( !p_sys )
|
||||
return VLC_ENOMEM;
|
||||
|
||||
p_intf->p_sys = p_sys;
|
||||
p_intf->pf_run = Run;
|
||||
|
|
|
@ -96,7 +96,9 @@ int Import_GVP( vlc_object_t *p_this )
|
|||
STANDARD_DEMUX_INIT_MSG( "using Google Video Playlist (gvp) import" );
|
||||
p_demux->pf_control = Control;
|
||||
p_demux->pf_demux = Demux;
|
||||
MALLOC_ERR( p_demux->p_sys, demux_sys_t );
|
||||
p_demux->p_sys = malloc( sizeof( demux_sys_t ) );
|
||||
if( !p_demux->p_sys )
|
||||
return VLC_ENOMEM;
|
||||
|
||||
return VLC_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -89,7 +89,9 @@ static int Open( vlc_object_t *p_this )
|
|||
intf_thread_t *p_intf = (intf_thread_t *)p_this;
|
||||
playlist_t *p_playlist;
|
||||
|
||||
MALLOC_ERR( p_intf->p_sys, intf_sys_t );
|
||||
p_intf->p_sys = malloc( sizeof( intf_sys_t ) );
|
||||
if( !p_intf->p_sys )
|
||||
return VLC_ENOMEM;
|
||||
|
||||
p_intf->p_sys->psz_format = config_GetPsz( p_intf, "msn-format" );
|
||||
if( !p_intf->p_sys->psz_format )
|
||||
|
|
|
@ -97,7 +97,9 @@ static int Open( vlc_object_t *p_this )
|
|||
DBusConnection *p_conn;
|
||||
DBusError error;
|
||||
|
||||
MALLOC_ERR( p_intf->p_sys, intf_sys_t );
|
||||
p_intf->p_sys = malloc( sizeof( intf_sys_t ) );
|
||||
if( !p_intf->p_sys )
|
||||
return VLC_ENOMEM;
|
||||
|
||||
/* connect to the session bus */
|
||||
dbus_error_init( &error );
|
||||
|
|
Loading…
Reference in New Issue