]> git.sesse.net Git - vlc/commitdiff
Remove MALLOC_(VOID|ERR). (and use calloc instead of malloc+memset)
authorRémi Duraffort <ivoire@videolan.org>
Sun, 2 Nov 2008 11:40:43 +0000 (12:40 +0100)
committerRémi Duraffort <ivoire@videolan.org>
Sun, 2 Nov 2008 11:40:43 +0000 (12:40 +0100)
include/vlc_access.h
include/vlc_common.h
include/vlc_demux.h
modules/control/hotkeys.c
modules/demux/playlist/gvp.c
modules/misc/notify/msn.c
modules/misc/notify/telepathy.c

index 821c01c8c98d9a4cbbd8b8b8570619cb208f4eed..32b7592700970b53b52cba48dfdcad037e79e658 100644 (file)
@@ -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
index 27d594d4655f5ea7a52f5bb8a97634db424e54ad..a637bad3c4f37b8a5a29ddbd5092ba92cf6b569e 100644 (file)
@@ -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)
 
index 6af44af48c4080d2edc27e86be072c48579ffb78..487efea45afdc29542ac19c84e55d3bb1de48b23 100644 (file)
@@ -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 { \
index 73b0e718279d798ef51c418f7c7316d5239d8e90..aaa6014197188053fe5f7eafd4186a9173f81ed0 100644 (file)
@@ -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;
index 19d6d3702b44b5425350b0e7753e4b2672d2160e..e66b95fc4a934b284ec1915bbf106c362785ba8b 100644 (file)
@@ -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;
 }
index a609cb452af237a216ec06e041f0cb6c35c53c36..1629ca8924a49558a3891ec9047274527ae92e70 100644 (file)
@@ -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 )
index 32b9e80802f735602e00eb9a6c29242fa858c21a..886b3f2a8fafe383a7ac051c6ccecb4891dfd89e 100644 (file)
@@ -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 );