Changeset 4a2ded0bad747c8d671f2321e8ac9e9c556e1d17

Show
Ignore:
Timestamp:
21/10/07 09:12:07 (1 year ago)
Author:
Rémi Denis-Courmont <rem@videolan.org>
git-committer:
Rémi Denis-Courmont <rem@videolan.org> 1192950727 +0000
git-parent:

[086d0746ed62770dbd0bdc473c18f41b604f0bb7]

git-author:
Rémi Denis-Courmont <rem@videolan.org> 1192950727 +0000
Message:

libvlc_exception:

  • add missing const qualifiers
  • prevent exception from being silented in case of ENOMEM
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • include/vlc/libvlc.h

    r7b32ae1 r4a2ded0  
    6262 * \return 0 if no exception raised, 1 else 
    6363 */ 
    64 VLC_PUBLIC_API int libvlc_exception_raised( libvlc_exception_t *p_exception ); 
     64VLC_PUBLIC_API int 
     65libvlc_exception_raised( const libvlc_exception_t *p_exception ); 
    6566 
    6667/** 
     
    6970 * \param psz_message the exception message 
    7071 */ 
    71 VLC_PUBLIC_API void libvlc_exception_raise( libvlc_exception_t *p_exception, const char *psz_format, ... ); 
     72VLC_PUBLIC_API void 
     73libvlc_exception_raise( libvlc_exception_t *p_exception, 
     74                        const char *psz_format, ... ); 
    7275 
    7376/** 
     
    8487 * for example) 
    8588 */ 
    86 VLC_PUBLIC_API char* libvlc_exception_get_message( libvlc_exception_t *p_exception ); 
     89VLC_PUBLIC_API const char * 
     90libvlc_exception_get_message( const libvlc_exception_t *p_exception ); 
    8791 
    8892/**@} */ 
  • include/vlc/libvlc_structures.h

    r7b32ae1 r4a2ded0  
    304304    libvlc_MediaInstanceReachedEnd, 
    305305    libvlc_MediaInstancePositionChanged, 
    306   
     306 
    307307    libvlc_MediaListItemAdded, 
    308308    libvlc_MediaListItemDeleted, 
  • src/control/core.c

    r6ee1e19 r4a2ded0  
    2727#include <vlc_interface.h> 
    2828 
     29static const char nomemstr[] = "Insufficient memory"; 
     30 
    2931/************************************************************************* 
    3032 * Exceptions handling 
     
    3840void libvlc_exception_clear( libvlc_exception_t *p_exception ) 
    3941{ 
    40     if( p_exception->psz_message
     42    if( p_exception->psz_message != nomemstr
    4143        free( p_exception->psz_message ); 
    4244    p_exception->psz_message = NULL; 
     
    4446} 
    4547 
    46 int libvlc_exception_raised( libvlc_exception_t *p_exception ) 
     48int libvlc_exception_raised( const libvlc_exception_t *p_exception ) 
    4749{ 
    4850    return (NULL != p_exception) && p_exception->b_raised; 
    4951} 
    5052 
    51 char *libvlc_exception_get_message( libvlc_exception_t *p_exception ) 
     53const char * 
     54libvlc_exception_get_message( const libvlc_exception_t *p_exception ) 
    5255{ 
    5356    if( p_exception->b_raised == 1 && p_exception->psz_message ) 
     
    6770 
    6871    /* remove previous exception if it wasn't cleared */ 
    69     if( p_exception->b_raised && p_exception->psz_message ) 
    70         free(p_exception->psz_message); 
     72    libvlc_exception_clear( p_exception ); 
    7173 
    7274    va_start( args, psz_format ); 
    7375    if( vasprintf( &p_exception->psz_message, psz_format, args ) == -1) 
    74         p_exception->psz_message = NULL
     76        p_exception->psz_message = (char *)nomemstr
    7577    va_end( args ); 
    7678