[vlc-devel] commit: Remove MALLOC_(VOID|ERR). (and use calloc instead of malloc+memset) ( Rémi Duraffort )
git version control
git at videolan.org
Sun Nov 2 12:41:59 CET 2008
vlc | branch: master | Rémi Duraffort <ivoire at videolan.org> | Sun Nov 2 12:40:43 2008 +0100| [12879a4c3b71a9d566a20a73a72430ca44b17e08] | committer: Rémi Duraffort
Remove MALLOC_(VOID|ERR). (and use calloc instead of malloc+memset)
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=12879a4c3b71a9d566a20a73a72430ca44b17e08
---
include/vlc_access.h | 34 +++++++++++++++++-----------------
include/vlc_common.h | 4 ----
include/vlc_demux.h | 3 ++-
modules/control/hotkeys.c | 4 +++-
modules/demux/playlist/gvp.c | 4 +++-
modules/misc/notify/msn.c | 4 +++-
modules/misc/notify/telepathy.c | 4 +++-
7 files changed, 31 insertions(+), 26 deletions(-)
diff --git a/include/vlc_access.h b/include/vlc_access.h
index 821c01c..32b7592 100644
--- a/include/vlc_access.h
+++ b/include/vlc_access.h
@@ -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 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_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 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 ); \
+ 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 ); \
+ p_sys = p_access->p_sys = calloc( 1, sizeof( access_sys_t ) ); \
+ if( !p_sys ) return VLC_ENOMEM;
#endif
diff --git a/include/vlc_common.h b/include/vlc_common.h
index 27d594d..a637bad 100644
--- a/include/vlc_common.h
+++ b/include/vlc_common.h
@@ -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)
diff --git a/include/vlc_demux.h b/include/vlc_demux.h
index 6af44af..487efea 100644
--- a/include/vlc_demux.h
+++ b/include/vlc_demux.h
@@ -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 { \
diff --git a/modules/control/hotkeys.c b/modules/control/hotkeys.c
index 73b0e71..aaa6014 100644
--- a/modules/control/hotkeys.c
+++ b/modules/control/hotkeys.c
@@ -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;
diff --git a/modules/demux/playlist/gvp.c b/modules/demux/playlist/gvp.c
index 19d6d37..e66b95f 100644
--- a/modules/demux/playlist/gvp.c
+++ b/modules/demux/playlist/gvp.c
@@ -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;
}
diff --git a/modules/misc/notify/msn.c b/modules/misc/notify/msn.c
index a609cb4..1629ca8 100644
--- a/modules/misc/notify/msn.c
+++ b/modules/misc/notify/msn.c
@@ -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 )
diff --git a/modules/misc/notify/telepathy.c b/modules/misc/notify/telepathy.c
index 32b9e80..886b3f2 100644
--- a/modules/misc/notify/telepathy.c
+++ b/modules/misc/notify/telepathy.c
@@ -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 );
More information about the vlc-devel
mailing list