1 /*****************************************************************************
2 * objects.c: vlc_object_t handling
3 *****************************************************************************
4 * Copyright (C) 2004-2008 the VideoLAN team
5 * Copyright (C) 2006-2010 RĂ©mi Denis-Courmont
7 * Authors: Samuel Hocevar <sam@zoy.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
26 * This file contains the functions to handle the vlc_object_t type
28 * Unless otherwise stated, functions in this file are not cancellation point.
29 * All functions in this file are safe w.r.t. deferred cancellation.
33 /*****************************************************************************
35 *****************************************************************************/
40 #include <vlc_common.h>
42 #include "../libvlc.h"
44 #include "audio_output/aout_internal.h"
46 #include "vlc_interface.h"
47 #include "vlc_codec.h"
49 #include "variables.h"
60 # include <winsock2.h>
61 # include <ws2tcpip.h>
63 # define read( a, b, c ) recv (a, b, c, 0)
65 # define write( a, b, c ) send (a, b, c, 0)
67 # define close( a ) closesocket (a)
73 #if defined (HAVE_SYS_EVENTFD_H)
74 # include <sys/eventfd.h>
76 # define EFD_CLOEXEC 0
77 # warning EFD_CLOEXEC missing. Consider updating libc.
82 /*****************************************************************************
84 *****************************************************************************/
85 static int DumpCommand( vlc_object_t *, char const *,
86 vlc_value_t, vlc_value_t, void * );
88 static vlc_object_t * FindParentName( vlc_object_t *, const char * );
89 static vlc_object_t * FindChildName ( vlc_object_internals_t *, const char * );
90 static void PrintObject( vlc_object_internals_t *, const char * );
91 static void DumpStructure( vlc_object_internals_t *, unsigned, char * );
93 static vlc_list_t * NewList ( int );
95 static void vlc_object_destroy( vlc_object_t *p_this );
97 /*****************************************************************************
98 * Local structure lock
99 *****************************************************************************/
100 static void libvlc_lock (libvlc_int_t *p_libvlc)
102 vlc_mutex_lock (&(libvlc_priv (p_libvlc)->structure_lock));
105 static void libvlc_unlock (libvlc_int_t *p_libvlc)
107 vlc_mutex_unlock (&(libvlc_priv (p_libvlc)->structure_lock));
110 #undef vlc_custom_create
111 void *vlc_custom_create( vlc_object_t *p_this, size_t i_size,
112 int i_type, const char *psz_type )
115 vlc_object_internals_t *p_priv;
118 * VLC objects are laid out as follow:
119 * - first the LibVLC-private per-object data,
120 * - then VLC_COMMON members from vlc_object_t,
121 * - finally, the type-specific data (if any).
123 * This function initializes the LibVLC and common data,
124 * and zeroes the rest.
126 p_priv = calloc( 1, sizeof( *p_priv ) + i_size );
130 assert (i_size >= sizeof (vlc_object_t));
131 p_new = (vlc_object_t *)(p_priv + 1);
133 p_priv->i_object_type = i_type;
134 p_new->psz_object_type = psz_type;
135 p_priv->psz_name = NULL;
137 p_new->b_die = false;
138 p_new->b_force = false;
140 p_new->psz_header = NULL;
143 p_new->i_flags = p_this->i_flags
144 & (OBJECT_FLAGS_NODBG|OBJECT_FLAGS_QUIET|OBJECT_FLAGS_NOINTERACT);
146 p_priv->var_root = NULL;
150 libvlc_int_t *self = (libvlc_int_t*)p_new;
151 p_new->p_libvlc = self;
152 vlc_mutex_init (&(libvlc_priv (self)->structure_lock));
156 p_new->p_libvlc = p_this->p_libvlc;
158 vlc_spin_init( &p_priv->ref_spin );
159 p_priv->i_refcount = 1;
160 p_priv->pf_destructor = NULL;
161 p_new->p_parent = NULL;
162 p_priv->first = NULL;
164 /* Initialize mutexes and condvars */
165 vlc_mutex_init( &p_priv->var_lock );
166 vlc_cond_init( &p_priv->var_wait );
167 p_priv->pipes[0] = p_priv->pipes[1] = -1;
169 if (p_new == VLC_OBJECT(p_new->p_libvlc))
170 { /* TODO: should be in src/libvlc.c */
171 int canc = vlc_savecancel ();
172 var_Create( p_new, "tree", VLC_VAR_STRING | VLC_VAR_ISCOMMAND );
173 var_AddCallback( p_new, "tree", DumpCommand, NULL );
174 var_Create( p_new, "vars", VLC_VAR_STRING | VLC_VAR_ISCOMMAND );
175 var_AddCallback( p_new, "vars", DumpCommand, NULL );
176 vlc_restorecancel (canc);
182 #undef vlc_object_create
184 * Allocates and initializes a vlc object.
186 * @param i_size object byte size
188 * @return the new object, or NULL on error.
190 void *vlc_object_create( vlc_object_t *p_this, size_t i_size )
192 return vlc_custom_create( p_this, i_size, VLC_OBJECT_GENERIC, "generic" );
195 #undef vlc_object_set_destructor
197 ****************************************************************************
198 * Set the destructor of a vlc object
200 * This function sets the destructor of the vlc object. It will be called
201 * when the object is destroyed when the its refcount reaches 0.
202 * (It is called by the internal function vlc_object_destroy())
203 *****************************************************************************/
204 void vlc_object_set_destructor( vlc_object_t *p_this,
205 vlc_destructor_t pf_destructor )
207 vlc_object_internals_t *p_priv = vlc_internals(p_this );
209 vlc_spin_lock( &p_priv->ref_spin );
210 p_priv->pf_destructor = pf_destructor;
211 vlc_spin_unlock( &p_priv->ref_spin );
214 static vlc_mutex_t name_lock = VLC_STATIC_MUTEX;
216 #undef vlc_object_set_name
217 int vlc_object_set_name(vlc_object_t *obj, const char *name)
219 vlc_object_internals_t *priv = vlc_internals(obj);
220 char *newname = name ? strdup (name) : NULL;
223 vlc_mutex_lock (&name_lock);
224 oldname = priv->psz_name;
225 priv->psz_name = newname;
226 vlc_mutex_unlock (&name_lock);
229 return (priv->psz_name || !name) ? VLC_SUCCESS : VLC_ENOMEM;
232 #undef vlc_object_get_name
233 char *vlc_object_get_name(const vlc_object_t *obj)
235 vlc_object_internals_t *priv = vlc_internals(obj);
238 vlc_mutex_lock (&name_lock);
239 name = priv->psz_name ? strdup (priv->psz_name) : NULL;
240 vlc_mutex_unlock (&name_lock);
246 ****************************************************************************
247 * Destroy a vlc object (Internal)
249 * This function destroys an object that has been previously allocated with
250 * vlc_object_create. The object's refcount must be zero and it must not be
251 * attached to other objects in any way.
253 * This function must be called with cancellation disabled (currently).
254 *****************************************************************************/
255 static void vlc_object_destroy( vlc_object_t *p_this )
257 vlc_object_internals_t *p_priv = vlc_internals( p_this );
259 /* Send a kill to the object's thread if applicable */
260 vlc_object_kill( p_this );
262 /* Call the custom "subclass" destructor */
263 if( p_priv->pf_destructor )
264 p_priv->pf_destructor( p_this );
266 /* Destroy the associated variables. */
267 var_DestroyAll( p_this );
269 vlc_cond_destroy( &p_priv->var_wait );
270 vlc_mutex_destroy( &p_priv->var_lock );
272 free( p_this->psz_header );
274 free( p_priv->psz_name );
276 vlc_spin_destroy( &p_priv->ref_spin );
277 if( p_priv->pipes[1] != -1 && p_priv->pipes[1] != p_priv->pipes[0] )
278 close( p_priv->pipes[1] );
279 if( p_priv->pipes[0] != -1 )
280 close( p_priv->pipes[0] );
281 if( VLC_OBJECT(p_this->p_libvlc) == p_this )
282 vlc_mutex_destroy (&(libvlc_priv ((libvlc_int_t *)p_this)->structure_lock));
290 * select()-able pipes emulated using Winsock
292 # define vlc_pipe selectable_pipe
293 static int selectable_pipe (int fd[2])
296 int addrlen = sizeof (addr);
298 SOCKET l = socket (PF_INET, SOCK_STREAM, IPPROTO_TCP), a,
299 c = socket (PF_INET, SOCK_STREAM, IPPROTO_TCP);
300 if ((l == INVALID_SOCKET) || (c == INVALID_SOCKET))
303 memset (&addr, 0, sizeof (addr));
304 addr.sin_family = AF_INET;
305 addr.sin_addr.s_addr = htonl (INADDR_LOOPBACK);
306 if (bind (l, (PSOCKADDR)&addr, sizeof (addr))
307 || getsockname (l, (PSOCKADDR)&addr, &addrlen)
309 || connect (c, (PSOCKADDR)&addr, addrlen))
312 a = accept (l, NULL, NULL);
313 if (a == INVALID_SOCKET)
324 if (l != INVALID_SOCKET)
326 if (c != INVALID_SOCKET)
332 static vlc_mutex_t pipe_lock = VLC_STATIC_MUTEX;
335 * Returns the readable end of a pipe that becomes readable once termination
336 * of the object is requested (vlc_object_kill()).
337 * This can be used to wake-up out of a select() or poll() event loop, such
338 * typically when doing network I/O.
340 * Note that the pipe will remain the same for the lifetime of the object.
341 * DO NOT read the pipe nor close it yourself. Ever.
343 * @param obj object that would be "killed"
344 * @return a readable pipe descriptor, or -1 on error.
346 int vlc_object_waitpipe( vlc_object_t *obj )
348 vlc_object_internals_t *internals = vlc_internals( obj );
350 vlc_mutex_lock (&pipe_lock);
351 if (internals->pipes[0] == -1)
353 /* This can only ever happen if someone killed us without locking: */
354 assert (internals->pipes[1] == -1);
356 /* pipe() is not a cancellation point, but write() is and eventfd() is
357 * unspecified (not in POSIX). */
358 int canc = vlc_savecancel ();
359 #if defined (HAVE_SYS_EVENTFD_H)
360 internals->pipes[0] = internals->pipes[1] = eventfd (0, EFD_CLOEXEC);
361 if (internals->pipes[0] == -1)
364 if (vlc_pipe (internals->pipes))
365 internals->pipes[0] = internals->pipes[1] = -1;
368 if (internals->pipes[0] != -1 && obj->b_die)
369 { /* Race condition: vlc_object_kill() already invoked! */
370 msg_Dbg (obj, "waitpipe: object already dying");
371 write (internals->pipes[1], &(uint64_t){ 1 }, sizeof (uint64_t));
373 vlc_restorecancel (canc);
375 vlc_mutex_unlock (&pipe_lock);
376 return internals->pipes[0];
379 #undef vlc_object_kill
381 * Requests termination of an object, cancels the object thread, and make the
382 * object wait pipe (if it exists) readable. Not a cancellation point.
384 void vlc_object_kill( vlc_object_t *p_this )
386 vlc_object_internals_t *priv = vlc_internals( p_this );
389 vlc_mutex_lock( &pipe_lock );
393 p_this->b_die = true;
396 /* This also serves as a memory barrier toward vlc_object_alive(): */
397 vlc_mutex_unlock( &pipe_lock );
401 int canc = vlc_savecancel ();
403 /* write _after_ setting b_die, so vlc_object_alive() returns false */
404 write (fd, &(uint64_t){ 1 }, sizeof (uint64_t));
405 msg_Dbg (p_this, "waitpipe: object killed");
406 vlc_restorecancel (canc);
410 static int objnamecmp(const vlc_object_t *obj, const char *name)
412 char *objname = vlc_object_get_name(obj);
416 int ret = strcmp (objname, name);
421 #undef vlc_object_find_name
423 * Finds a named object and increment its reference count.
424 * Beware that objects found in this manner can be "owned" by another thread,
425 * be of _any_ type, and be attached to any module (if any). With such an
426 * object reference, you can set or get object variables, emit log messages,
427 * and read write-once object parameters (psz_object_type, etc).
428 * You CANNOT cast the object to a more specific object type, and you
429 * definitely cannot invoke object type-specific callbacks with this.
431 * @param p_this object to search from
432 * @param psz_name name of the object to search for
433 * @param i_mode search direction: FIND_PARENT, FIND_CHILD or FIND_ANYWHERE.
435 * @return a matching object (must be released by the caller),
438 vlc_object_t *vlc_object_find_name( vlc_object_t *p_this,
439 const char *psz_name, int i_mode )
441 vlc_object_t *p_found;
443 /* Reading psz_object_name from a separate inhibits thread-safety.
444 * Use a libvlc address variable instead for that sort of things! */
445 msg_Warn( p_this, "%s(%s) is not safe!", __func__, psz_name );
446 /* If have the requested name ourselves, don't look further */
447 if( !objnamecmp(p_this, psz_name) )
449 vlc_object_hold( p_this );
453 /* Otherwise, recursively look for the object */
454 if (i_mode == FIND_ANYWHERE)
455 return vlc_object_find_name (VLC_OBJECT(p_this->p_libvlc), psz_name,
458 libvlc_lock (p_this->p_libvlc);
459 vlc_mutex_lock (&name_lock);
463 p_found = FindParentName (p_this, psz_name);
466 p_found = FindChildName (vlc_internals (p_this), psz_name);
471 vlc_mutex_unlock (&name_lock);
472 libvlc_unlock (p_this->p_libvlc);
476 #undef vlc_object_hold
478 * Increment an object reference counter.
480 void * vlc_object_hold( vlc_object_t *p_this )
482 vlc_object_internals_t *internals = vlc_internals( p_this );
484 vlc_spin_lock( &internals->ref_spin );
485 /* Avoid obvious freed object uses */
486 assert( internals->i_refcount > 0 );
487 /* Increment the counter */
488 internals->i_refcount++;
489 vlc_spin_unlock( &internals->ref_spin );
493 #undef vlc_object_release
494 /*****************************************************************************
495 * Decrement an object refcount
496 * And destroy the object if its refcount reach zero.
497 *****************************************************************************/
498 void vlc_object_release( vlc_object_t *p_this )
500 vlc_object_internals_t *internals = vlc_internals( p_this );
501 vlc_object_t *parent = NULL;
502 bool b_should_destroy;
504 vlc_spin_lock( &internals->ref_spin );
505 assert( internals->i_refcount > 0 );
507 if( internals->i_refcount > 1 )
510 /* There are still other references to the object */
511 internals->i_refcount--;
512 vlc_spin_unlock( &internals->ref_spin );
515 vlc_spin_unlock( &internals->ref_spin );
518 /* Remember that we cannot hold the spin while waiting on the mutex */
519 libvlc_lock (p_this->p_libvlc);
520 /* Take the spin again. Note that another thread may have held the
521 * object in the (very short) mean time. */
522 vlc_spin_lock( &internals->ref_spin );
523 b_should_destroy = --internals->i_refcount == 0;
524 vlc_spin_unlock( &internals->ref_spin );
526 if( b_should_destroy )
528 /* Detach from parent to protect against FIND_CHILDREN */
529 parent = p_this->p_parent;
533 if (internals->prev != NULL)
534 internals->prev->next = internals->next;
536 vlc_internals(parent)->first = internals->next;
537 if (internals->next != NULL)
538 internals->next->prev = internals->prev;
541 /* We have no children */
542 assert (internals->first == NULL);
544 libvlc_unlock (p_this->p_libvlc);
546 if( b_should_destroy )
550 canc = vlc_savecancel ();
551 vlc_object_destroy( p_this );
552 vlc_restorecancel (canc);
554 vlc_object_release (parent);
558 #undef vlc_object_attach
560 ****************************************************************************
561 * attach object to a parent object
562 *****************************************************************************
563 * This function sets p_this as a child of p_parent, and p_parent as a parent
565 *****************************************************************************/
566 void vlc_object_attach( vlc_object_t *p_this, vlc_object_t *p_parent )
568 if( !p_this ) return;
570 vlc_object_internals_t *pap = vlc_internals (p_parent);
571 vlc_object_internals_t *priv = vlc_internals (p_this);
574 vlc_object_hold (p_parent);
575 libvlc_lock (p_this->p_libvlc);
577 /* Attach the parent to its child */
578 assert (p_this->p_parent == NULL);
579 p_this->p_parent = p_parent;
581 /* Attach the child to its parent */
582 priv->next = pap->first;
583 if (priv->next != NULL)
584 priv->next->prev = priv;
586 libvlc_unlock (p_this->p_libvlc);
590 #undef vlc_list_children
592 * Gets the list of children of an objects, and increment their reference
594 * @return a list (possibly empty) or NULL in case of error.
596 vlc_list_t *vlc_list_children( vlc_object_t *obj )
599 vlc_object_internals_t *priv;
602 libvlc_lock (obj->p_libvlc);
603 for (priv = vlc_internals (obj)->first; priv; priv = priv->next)
606 if (likely(l != NULL))
610 for (priv = vlc_internals (obj)->first; priv; priv = priv->next)
611 l->p_values[i++].p_object = vlc_object_hold (vlc_externals (priv));
613 libvlc_unlock (obj->p_libvlc);
617 static void DumpVariable (const void *data, const VISIT which, const int depth)
619 if (which != postorder && which != leaf)
623 const variable_t *p_var = *(const variable_t **)data;
624 const char *psz_type = "unknown";
626 switch( p_var->i_type & VLC_VAR_TYPE )
628 #define MYCASE( type, nice ) \
629 case VLC_VAR_ ## type: \
632 MYCASE( VOID, "void" );
633 MYCASE( BOOL, "bool" );
634 MYCASE( INTEGER, "integer" );
635 MYCASE( HOTKEY, "hotkey" );
636 MYCASE( STRING, "string" );
637 MYCASE( VARIABLE, "variable" );
638 MYCASE( FLOAT, "float" );
639 MYCASE( TIME, "time" );
640 MYCASE( COORDS, "coords" );
641 MYCASE( ADDRESS, "address" );
642 MYCASE( MUTEX, "mutex" );
645 printf( " *-o \"%s\" (%s", p_var->psz_name, psz_type );
646 if( p_var->psz_text )
647 printf( ", %s", p_var->psz_text );
648 fputc( ')', stdout );
649 if( p_var->i_type & VLC_VAR_HASCHOICE )
650 fputs( ", has choices", stdout );
651 if( p_var->i_type & VLC_VAR_ISCOMMAND )
652 fputs( ", command", stdout );
653 if( p_var->i_entries )
654 printf( ", %d callbacks", p_var->i_entries );
655 switch( p_var->i_type & VLC_VAR_CLASS )
661 printf( ": %s", p_var->val.b_bool ? "true" : "false" );
663 case VLC_VAR_INTEGER:
664 printf( ": %"PRId64, p_var->val.i_int );
667 printf( ": \"%s\"", p_var->val.psz_string );
670 printf( ": %f", p_var->val.f_float );
673 printf( ": %"PRIi64, (int64_t)p_var->val.i_time );
676 printf( ": %"PRId32"x%"PRId32,
677 p_var->val.coords.x, p_var->val.coords.y );
679 case VLC_VAR_ADDRESS:
680 printf( ": %p", p_var->val.p_address );
683 fputc( '\n', stdout );
686 /*****************************************************************************
687 * DumpCommand: print the current vlc structure
688 *****************************************************************************
689 * This function prints either an ASCII tree showing the connections between
690 * vlc objects, and additional information such as their refcount, thread ID,
691 * etc. (command "tree"), or the same data as a simple list (command "list").
692 *****************************************************************************/
693 static int DumpCommand( vlc_object_t *p_this, char const *psz_cmd,
694 vlc_value_t oldval, vlc_value_t newval, void *p_data )
696 (void)oldval; (void)p_data;
697 vlc_object_t *p_object = NULL;
699 if( *newval.psz_string )
701 /* try using the object's name to find it */
702 p_object = vlc_object_find_name( p_this, newval.psz_string,
710 libvlc_lock (p_this->p_libvlc);
711 if( *psz_cmd == 't' )
713 char psz_foo[2 * MAX_DUMPSTRUCTURE_DEPTH + 1];
716 p_object = VLC_OBJECT(p_this->p_libvlc);
719 DumpStructure( vlc_internals(p_object), 0, psz_foo );
721 else if( *psz_cmd == 'v' )
724 p_object = p_this->p_libvlc ? VLC_OBJECT(p_this->p_libvlc) : p_this;
726 PrintObject( vlc_internals(p_object), "" );
727 vlc_mutex_lock( &vlc_internals( p_object )->var_lock );
728 if( vlc_internals( p_object )->var_root == NULL )
729 puts( " `-o No variables" );
731 twalk( vlc_internals( p_object )->var_root, DumpVariable );
732 vlc_mutex_unlock( &vlc_internals( p_object )->var_lock );
734 libvlc_unlock (p_this->p_libvlc);
736 if( *newval.psz_string )
738 vlc_object_release( p_object );
743 /*****************************************************************************
744 * vlc_list_release: free a list previously allocated by vlc_list_find
745 *****************************************************************************
746 * This function decreases the refcount of all objects in the list and
748 *****************************************************************************/
749 void vlc_list_release( vlc_list_t *p_list )
753 for( i_index = 0; i_index < p_list->i_count; i_index++ )
755 vlc_object_release( p_list->p_values[i_index].p_object );
758 free( p_list->p_values );
762 /* Following functions are local */
764 static vlc_object_t *FindParentName (vlc_object_t *p_this, const char *name)
766 for (vlc_object_t *parent = p_this->p_parent;
768 parent = parent->p_parent)
770 const char *objname = vlc_internals (parent)->psz_name;
771 if (objname && !strcmp (objname, name))
772 return vlc_object_hold (parent);
777 static vlc_object_t *FindChildName (vlc_object_internals_t *priv,
780 for (priv = priv->first; priv != NULL; priv = priv->next)
782 if (priv->psz_name && !strcmp (priv->psz_name, name))
783 return vlc_object_hold (vlc_externals (priv));
785 vlc_object_t *found = FindChildName (priv, name);
792 static void PrintObject( vlc_object_internals_t *priv,
793 const char *psz_prefix )
795 char psz_refcount[20], psz_name[50], psz_parent[20];
797 int canc = vlc_savecancel ();
798 memset( &psz_name, 0, sizeof(psz_name) );
800 vlc_mutex_lock (&name_lock);
801 if (priv->psz_name != NULL)
803 snprintf( psz_name, 49, " \"%s\"", priv->psz_name );
807 vlc_mutex_unlock (&name_lock);
809 psz_refcount[0] = '\0';
810 if( priv->i_refcount > 0 )
811 snprintf( psz_refcount, 19, ", %u refs", priv->i_refcount );
813 psz_parent[0] = '\0';
814 /* FIXME: need structure lock!!! */
815 if( vlc_externals(priv)->p_parent )
816 snprintf( psz_parent, 19, ", parent %p",
817 vlc_externals(priv)->p_parent );
819 printf( " %so %p %s%s%s%s\n", psz_prefix,
820 vlc_externals(priv), vlc_externals(priv)->psz_object_type,
821 psz_name, psz_refcount, psz_parent );
822 vlc_restorecancel (canc);
825 static void DumpStructure (vlc_object_internals_t *priv, unsigned i_level,
828 char i_back = psz_foo[i_level];
829 psz_foo[i_level] = '\0';
831 PrintObject (priv, psz_foo);
833 psz_foo[i_level] = i_back;
835 if( i_level / 2 >= MAX_DUMPSTRUCTURE_DEPTH )
837 msg_Warn( vlc_externals(priv), "structure tree is too deep" );
841 for (priv = priv->first; priv != NULL; priv = priv->next)
845 psz_foo[i_level-1] = ' ';
847 if( psz_foo[i_level-2] == '`' )
849 psz_foo[i_level-2] = ' ';
853 psz_foo[i_level] = priv->next ? '|' : '`';
854 psz_foo[i_level+1] = '-';
855 psz_foo[i_level+2] = '\0';
857 DumpStructure (priv, i_level + 2, psz_foo);
861 static vlc_list_t * NewList( int i_count )
863 vlc_list_t * p_list = malloc( sizeof( vlc_list_t ) );
867 p_list->i_count = i_count;
871 p_list->p_values = NULL;
875 p_list->p_values = malloc( i_count * sizeof( vlc_value_t ) );
876 if( p_list->p_values == NULL )