[vlc-devel] commit: LibVLC log: remove exceptions ( Rémi Denis-Courmont )
git version control
git at videolan.org
Sun Jan 31 20:13:43 CET 2010
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Jan 31 21:13:18 2010 +0200| [595e377e334bff112c55d2799467173adff71001] | committer: Rémi Denis-Courmont
LibVLC log: remove exceptions
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=595e377e334bff112c55d2799467173adff71001
---
include/vlc/libvlc.h | 16 +++++---------
src/control/log.c | 56 +++++++++++++++++++++++++------------------------
2 files changed, 35 insertions(+), 37 deletions(-)
diff --git a/include/vlc/libvlc.h b/include/vlc/libvlc.h
index 38f4dc2..ed07d2c 100644
--- a/include/vlc/libvlc.h
+++ b/include/vlc/libvlc.h
@@ -339,10 +339,9 @@ VLC_PUBLIC_API void libvlc_set_log_verbosity( libvlc_instance_t *p_instance, uns
* Open a VLC message log instance.
*
* \param p_instance libvlc instance
- * \param p_e an initialized exception pointer
- * \return log message instance
+ * \return log message instance or NULL on error
*/
-VLC_PUBLIC_API libvlc_log_t *libvlc_log_open( libvlc_instance_t *, libvlc_exception_t *);
+VLC_PUBLIC_API libvlc_log_t *libvlc_log_open( libvlc_instance_t *);
/**
* Close a VLC message log instance.
@@ -373,10 +372,9 @@ VLC_PUBLIC_API void libvlc_log_clear( libvlc_log_t *p_log );
* Allocate and returns a new iterator to messages in log.
*
* \param p_log libvlc log instance
- * \param p_e an initialized exception pointer
- * \return log iterator object
+ * \return log iterator object or NULL on error
*/
-VLC_PUBLIC_API libvlc_log_iterator_t *libvlc_log_get_iterator( const libvlc_log_t *, libvlc_exception_t *);
+VLC_PUBLIC_API libvlc_log_iterator_t *libvlc_log_get_iterator( const libvlc_log_t * );
/**
* Release a previoulsy allocated iterator.
@@ -400,12 +398,10 @@ VLC_PUBLIC_API int libvlc_log_iterator_has_next( const libvlc_log_iterator_t *p_
*
* \param p_iter libvlc log iterator or NULL
* \param p_buffer log buffer
- * \param p_e an initialized exception pointer
- * \return log message object
+ * \return log message object or NULL if none left
*/
VLC_PUBLIC_API libvlc_log_message_t *libvlc_log_iterator_next( libvlc_log_iterator_t *p_iter,
- libvlc_log_message_t *p_buffer,
- libvlc_exception_t *p_e );
+ libvlc_log_message_t *p_buffer );
/** @} */
diff --git a/src/control/log.c b/src/control/log.c
index e6b066d..5442870 100644
--- a/src/control/log.c
+++ b/src/control/log.c
@@ -89,12 +89,14 @@ void libvlc_set_log_verbosity( libvlc_instance_t *p_instance, unsigned level )
p_instance->verbosity = level;
}
-libvlc_log_t *libvlc_log_open( libvlc_instance_t *p_instance, libvlc_exception_t *p_e )
+libvlc_log_t *libvlc_log_open( libvlc_instance_t *p_instance )
{
- struct libvlc_log_t *p_log =
- (struct libvlc_log_t *)malloc(sizeof(struct libvlc_log_t));
-
- if( !p_log ) RAISENULL( "Out of memory" );
+ struct libvlc_log_t *p_log = malloc(sizeof(*p_log));
+ if (unlikely(p_log == NULL))
+ {
+ libvlc_printerr ("Not enough memory");
+ return NULL;
+ }
p_log->p_instance = p_instance;
vlc_spin_init( &p_log->data.lock );
@@ -105,7 +107,8 @@ libvlc_log_t *libvlc_log_open( libvlc_instance_t *p_instance, libvlc_exception_t
if( !p_log->p_messages )
{
free( p_log );
- RAISENULL( "Out of memory" );
+ libvlc_printerr ("Not enough memory");
+ return NULL;
}
libvlc_retain( p_instance );
@@ -156,27 +159,27 @@ void libvlc_log_clear( libvlc_log_t *p_log )
msg_Release (tab[i]);
}
-libvlc_log_iterator_t *libvlc_log_get_iterator( const libvlc_log_t *p_log,
- libvlc_exception_t *p_e )
+libvlc_log_iterator_t *libvlc_log_get_iterator( const libvlc_log_t *p_log )
{
- if( p_log )
- {
- struct libvlc_log_iterator_t *p_iter =
- (struct libvlc_log_iterator_t *)malloc(sizeof(struct libvlc_log_iterator_t));
- /* FIXME: break constant pointer constraints */
- msg_cb_data_t *data = &((libvlc_log_t *)p_log)->data;
+ if (p_log == NULL)
+ return NULL;
- if( !p_iter ) RAISENULL( "Out of memory" );
+ struct libvlc_log_iterator_t *p_iter = malloc (sizeof (*p_iter));
+ if (unlikely(p_iter == NULL))
+ {
+ libvlc_printerr ("Not enough memory");
+ return NULL;
+ }
- vlc_spin_lock (&data->lock);
- p_iter->p_data = data;
- p_iter->i_pos = 0;
- p_iter->i_end = data->count;
- vlc_spin_unlock (&data->lock);
+ /* FIXME: break constant pointer constraints */
+ msg_cb_data_t *data = &((libvlc_log_t *)p_log)->data;
- return p_iter;
- }
- RAISENULL("Invalid log object!");
+ vlc_spin_lock (&data->lock);
+ p_iter->p_data = data;
+ p_iter->i_pos = 0;
+ p_iter->i_end = data->count;
+ vlc_spin_unlock (&data->lock);
+ return p_iter;
}
void libvlc_log_iterator_free( libvlc_log_iterator_t *p_iter )
@@ -192,14 +195,13 @@ int libvlc_log_iterator_has_next( const libvlc_log_iterator_t *p_iter )
}
libvlc_log_message_t *libvlc_log_iterator_next( libvlc_log_iterator_t *p_iter,
- libvlc_log_message_t *buffer,
- libvlc_exception_t *p_e )
+ libvlc_log_message_t *buffer )
{
unsigned i_pos;
if( !p_iter )
return NULL;
- assert( buffer );
+ assert (buffer != NULL);
i_pos = p_iter->i_pos;
if( i_pos != p_iter->i_end )
@@ -217,5 +219,5 @@ libvlc_log_message_t *libvlc_log_iterator_next( libvlc_log_iterator_t *p_iter,
return buffer;
}
- RAISENULL("No more messages");
+ return NULL;
}
More information about the vlc-devel
mailing list