char * psz_message;
} msg_context_t;
+static void cleanup_msg_context (void *data)
+{
+ msg_context_t *ctx = data;
+ free (ctx->psz_message);
+ free (ctx);
+}
+
static vlc_threadvar_t msg_context;
static uintptr_t banks = 0;
vlc_mutex_lock( &msg_stack_lock );
if( banks++ == 0 )
- vlc_threadvar_create( &msg_context, NULL );
+ vlc_threadvar_create( &msg_context, cleanup_msg_context );
vlc_mutex_unlock( &msg_stack_lock );
}
* Destroy the message queues
*
* This functions prints all messages remaining in the queues,
- * then frees all the allocated ressources
+ * then frees all the allocated resources
* No other messages interface functions should be called after this one.
*/
void msg_Destroy (libvlc_int_t *p_libvlc)
vlc_mutex_unlock (&bank->lock);
vlc_join (sub->thread, NULL);
+
+ /* Free dangling (not flushed) messages. */
+ /* NOTE: no locking, only this thread can refer to the subscription now. */
+ while (sub->begin != sub->end)
+ {
+ msg_Release (sub->items[sub->begin]);
+ if (++sub->begin == VLC_MSG_QSIZE)
+ sub->begin = 0;
+ }
free (sub);
}
char * psz_str = NULL; /* formatted message string */
char * psz_header = NULL;
va_list args;
- msg_item_t * p_item = malloc (sizeof (*p_item));
-
- if (p_item == NULL)
- return; /* Uho! */
-
- vlc_gc_init (p_item, msg_Free);
- p_item->psz_module = p_item->psz_msg = p_item->psz_header = NULL;
if( p_this->i_flags & OBJECT_FLAGS_QUIET ||
(p_this->i_flags & OBJECT_FLAGS_NODBG && i_type == VLC_MSG_DBG) )
- goto out;
+ return;
#ifndef __GLIBC__
/* Expand %m to strerror(errno) - only once */
va_end( args );
fputs( "\n", stderr );
vlc_restorecancel (canc);
- goto out;
+ return;
}
+ msg_item_t * p_item = malloc (sizeof (*p_item));
+
+ if (p_item == NULL)
+ return; /* Uho! */
+
+ vlc_gc_init (p_item, msg_Free);
+ p_item->psz_module = p_item->psz_msg = p_item->psz_header = NULL;
+
+
+
i_header_size = 0;
p_obj = p_this;
while( p_obj != NULL )
p_obj = p_obj->p_parent;
}
- msg_bank_t *p_queue = &QUEUE;
- vlc_mutex_lock( &p_queue->lock );
-
/* Fill message information fields */
p_item->i_type = i_type;
p_item->i_object_id = (uintptr_t)p_this;
p_item->psz_header = psz_header;
PrintMsg( p_this, p_item );
+
+ msg_bank_t *p_queue = &QUEUE;
+ vlc_mutex_lock( &p_queue->lock );
#define bank p_queue
for (int i = 0; i < bank->i_sub; i++)
{
}
vlc_cond_broadcast (&bank->wait);
vlc_mutex_unlock (&bank->lock);
-out:
msg_Release (p_item);
}
return;
}
- int canc = vlc_savecancel ();
#ifdef UNDER_CE
# define CE_WRITE(str) WriteFile( QUEUE.logfile, \
str, strlen(str), &i_dummy, NULL );
FlushFileBuffers( QUEUE.logfile );
#else
+ int canc = vlc_savecancel ();
/* Send the message to stderr */
utf8_fprintf( stderr, "[%s%p%s] %s%s%s %s%s: %s%s%s\n",
priv->b_color ? GREEN : "",
static msg_context_t* GetContext(void)
{
- msg_context_t *p_ctx = vlc_threadvar_get( &msg_context );
+ msg_context_t *p_ctx = vlc_threadvar_get( msg_context );
if( p_ctx == NULL )
{
- MALLOC_NULL( p_ctx, msg_context_t );
+ p_ctx = malloc( sizeof( msg_context_t ) );
+ if( !p_ctx )
+ return NULL;
p_ctx->psz_message = NULL;
- vlc_threadvar_set( &msg_context, p_ctx );
+ vlc_threadvar_set( msg_context, p_ctx );
}
return p_ctx;
}