Commit 0c86c2c9 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Allocate message item on the stack

parent 9fd97f34
...@@ -261,10 +261,8 @@ void msg_GenericVa (vlc_object_t *p_this, int i_type, ...@@ -261,10 +261,8 @@ void msg_GenericVa (vlc_object_t *p_this, int i_type,
const char *psz_module, const char *psz_module,
const char *psz_format, va_list _args) const char *psz_format, va_list _args)
{ {
size_t i_header_size; /* Size of the additionnal header */
vlc_object_t *p_obj; vlc_object_t *p_obj;
char * psz_str = NULL; /* formatted message string */ char * psz_str = NULL; /* formatted message string */
char * psz_header = NULL;
va_list args; va_list args;
assert (p_this); assert (p_this);
...@@ -366,14 +364,18 @@ void msg_GenericVa (vlc_object_t *p_this, int i_type, ...@@ -366,14 +364,18 @@ void msg_GenericVa (vlc_object_t *p_this, int i_type,
} }
uselocale (locale); uselocale (locale);
msg_item_t * p_item = malloc (sizeof (*p_item)); /* Fill message information fields */
if (p_item == NULL) msg_item_t msg;
return; /* Uho! */
p_item->psz_module = p_item->psz_msg = p_item->psz_header = NULL; msg.i_type = i_type;
msg.i_object_id = (uintptr_t)p_this;
msg.psz_object_type = p_this->psz_object_type;
msg.psz_module = strdup( psz_module );
msg.psz_msg = psz_str;
char *psz_header = NULL;
size_t i_header_size = 0;
i_header_size = 0;
p_obj = p_this; p_obj = p_this;
while( p_obj != NULL ) while( p_obj != NULL )
{ {
...@@ -399,15 +401,9 @@ void msg_GenericVa (vlc_object_t *p_this, int i_type, ...@@ -399,15 +401,9 @@ void msg_GenericVa (vlc_object_t *p_this, int i_type,
p_obj = p_obj->p_parent; p_obj = p_obj->p_parent;
} }
/* Fill message information fields */ msg.psz_header = psz_header;
p_item->i_type = i_type;
p_item->i_object_id = (uintptr_t)p_this;
p_item->psz_object_type = p_this->psz_object_type;
p_item->psz_module = strdup( psz_module );
p_item->psz_msg = psz_str;
p_item->psz_header = psz_header;
PrintMsg( p_this, p_item ); PrintMsg( p_this, &msg );
vlc_rwlock_rdlock (&bank->lock); vlc_rwlock_rdlock (&bank->lock);
for (int i = 0; i < bank->i_sub; i++) for (int i = 0; i < bank->i_sub; i++)
...@@ -416,17 +412,17 @@ void msg_GenericVa (vlc_object_t *p_this, int i_type, ...@@ -416,17 +412,17 @@ void msg_GenericVa (vlc_object_t *p_this, int i_type,
libvlc_priv_t *priv = libvlc_priv( sub->instance ); libvlc_priv_t *priv = libvlc_priv( sub->instance );
msg_bank_t *bank = priv->msg_bank; msg_bank_t *bank = priv->msg_bank;
void *val = vlc_dictionary_value_for_key( &bank->enabled_objects, void *val = vlc_dictionary_value_for_key( &bank->enabled_objects,
p_item->psz_module ); msg.psz_module );
if( val == kObjectPrintingDisabled ) continue; if( val == kObjectPrintingDisabled ) continue;
if( val != kObjectPrintingEnabled ) /*if not allowed */ if( val != kObjectPrintingEnabled ) /*if not allowed */
{ {
val = vlc_dictionary_value_for_key( &bank->enabled_objects, val = vlc_dictionary_value_for_key( &bank->enabled_objects,
p_item->psz_object_type ); msg.psz_object_type );
if( val == kObjectPrintingDisabled ) continue; if( val == kObjectPrintingDisabled ) continue;
if( val == kObjectPrintingEnabled ); /* Allowed */ if( val == kObjectPrintingEnabled ); /* Allowed */
else if( !bank->all_objects_enabled ) continue; else if( !bank->all_objects_enabled ) continue;
} }
switch( p_item->i_type ) switch( msg.i_type )
{ {
case VLC_MSG_INFO: case VLC_MSG_INFO:
case VLC_MSG_ERR: case VLC_MSG_ERR:
...@@ -440,10 +436,12 @@ void msg_GenericVa (vlc_object_t *p_this, int i_type, ...@@ -440,10 +436,12 @@ void msg_GenericVa (vlc_object_t *p_this, int i_type,
break; break;
} }
sub->func (sub->opaque, p_item, 0); sub->func (sub->opaque, &msg, 0);
} }
vlc_rwlock_unlock (&bank->lock); vlc_rwlock_unlock (&bank->lock);
msg_Free (p_item); free (msg.psz_module);
free (msg.psz_msg);
free (msg.psz_header);
} }
/***************************************************************************** /*****************************************************************************
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment