VLC  4.0.0-dev
vlc_arrays.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * vlc_arrays.h : Arrays and data structures handling
3  *****************************************************************************
4  * Copyright (C) 1999-2004 VLC authors and VideoLAN
5  *
6  * Authors: Samuel Hocevar <sam@zoy.org>
7  * ClĂ©ment Stenac <zorglub@videolan.org>
8  *
9  * This program is free software; you can redistribute it and/or modify it
10  * under the terms of the GNU Lesser General Public License as published by
11  * the Free Software Foundation; either version 2.1 of the License, or
12  * (at your option) any later version.
13  *
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 Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public License
20  * along with this program; if not, write to the Free Software Foundation,
21  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23 
24 #ifndef VLC_ARRAYS_H_
25 #define VLC_ARRAYS_H_
26 
27 /**
28  * \file
29  * This file defines functions, structures and macros for handling arrays in vlc
30  */
31 
32 /* realloc() that never fails *if* downsizing */
33 static inline void *realloc_down( void *ptr, size_t size )
34 {
35  void *ret = realloc( ptr, size );
36  return ret ? ret : ptr;
37 }
38 
39 /**
40  * This wrapper around realloc() will free the input pointer when
41  * realloc() returns NULL. The use case ptr = realloc(ptr, newsize) will
42  * cause a memory leak when ptr pointed to a heap allocation before,
43  * leaving the buffer allocated but unreferenced. vlc_realloc() is a
44  * drop-in replacement for that use case (and only that use case).
45  */
46 static inline void *realloc_or_free( void *p, size_t sz )
47 {
48  void *n = realloc(p,sz);
49  if( !n )
50  free(p);
51  return n;
52 }
53 
54 #define TAB_INIT( count, tab ) \
55  do { \
56  (count) = 0; \
57  (tab) = NULL; \
58  } while(0)
59 
60 #define TAB_CLEAN( count, tab ) \
61  do { \
62  free( tab ); \
63  (count)= 0; \
64  (tab)= NULL; \
65  } while(0)
66 
67 #define TAB_APPEND_CAST( cast, count, tab, p ) \
68  do { \
69  if( (count) > 0 ) \
70  (tab) = cast realloc( tab, sizeof( *(tab) ) * ( (count) + 1 ) ); \
71  else \
72  (tab) = cast malloc( sizeof( *(tab) ) ); \
73  if( !(tab) ) abort(); \
74  (tab)[count] = (p); \
75  (count)++; \
76  } while(0)
77 
78 #define TAB_APPEND( count, tab, p ) \
79  TAB_APPEND_CAST( , count, tab, p )
80 
81 #define TAB_FIND( count, tab, p, idx ) \
82  do { \
83  for( (idx) = 0; (idx) < (count); (idx)++ ) \
84  if( (tab)[(idx)] == (p) ) \
85  break; \
86  if( (idx) >= (count) ) \
87  (idx) = -1; \
88  } while(0)
89 
90 
91 #define TAB_ERASE( count, tab, index ) \
92  do { \
93  if( (count) > 1 ) \
94  memmove( (tab) + (index), \
95  (tab) + (index) + 1, \
96  ((count) - (index) - 1 ) * sizeof( *(tab) ) );\
97  (count)--; \
98  if( (count) == 0 ) \
99  { \
100  free( tab ); \
101  (tab) = NULL; \
102  } \
103  } while(0)
104 
105 #define TAB_REMOVE( count, tab, p ) \
106  do { \
107  int i_index; \
108  TAB_FIND( count, tab, p, i_index ); \
109  if( i_index >= 0 ) \
110  TAB_ERASE( count, tab, i_index ); \
111  } while(0)
112 
113 #define TAB_INSERT_CAST( cast, count, tab, p, index ) do { \
114  if( (count) > 0 ) \
115  (tab) = cast realloc( tab, sizeof( *(tab) ) * ( (count) + 1 ) ); \
116  else \
117  (tab) = cast malloc( sizeof( *(tab) ) ); \
118  if( !(tab) ) abort(); \
119  if( (count) - (index) > 0 ) \
120  memmove( (tab) + (index) + 1, \
121  (tab) + (index), \
122  ((count) - (index)) * sizeof( *(tab) ) );\
123  (tab)[(index)] = (p); \
124  (count)++; \
125 } while(0)
126 
127 #define TAB_INSERT( count, tab, p, index ) \
128  TAB_INSERT_CAST( , count, tab, p, index )
129 
130 /**
131  * Binary search in a sorted array. The key must be comparable by < and >
132  * \param entries array of entries
133  * \param count number of entries
134  * \param elem key to check within an entry (like .id, or ->i_id)
135  * \param zetype type of the key
136  * \param key value of the key
137  * \param answer index of answer within the array. -1 if not found
138  */
139 #define BSEARCH( entries, count, elem, zetype, key, answer ) \
140  do { \
141  int low = 0, high = count - 1; \
142  answer = -1; \
143  while( low <= high ) {\
144  int mid = ((unsigned int)low + (unsigned int)high) >> 1;\
145  zetype mid_val = entries[mid] elem;\
146  if( mid_val < key ) \
147  low = mid + 1; \
148  else if ( mid_val > key ) \
149  high = mid -1; \
150  else \
151  { \
152  answer = mid; break; \
153  }\
154  } \
155  } while(0)
156 
157 
158 /************************************************************************
159  * Dynamic arrays with progressive allocation
160  ************************************************************************/
161 
162 /* Internal functions */
163 #define _ARRAY_ALLOC(array, newsize) { \
164  (array).i_alloc = newsize; \
165  (array).p_elems = realloc( (array).p_elems, (array).i_alloc * \
166  sizeof(*(array).p_elems) ); \
167  if( !(array).p_elems ) abort(); \
168 }
169 
170 #define _ARRAY_GROW1(array) { \
171  if( (array).i_alloc < 10 ) \
172  _ARRAY_ALLOC(array, 10 ) \
173  else if( (array).i_alloc == (array).i_size ) \
174  _ARRAY_ALLOC(array, (int)((array).i_alloc * 1.5) ) \
175 }
176 
177 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
178 
179 /* API */
180 #define DECL_ARRAY(type) struct { \
181  int i_alloc; \
182  int i_size; \
183  type *p_elems; \
184 }
185 
186 #define TYPEDEF_ARRAY(type, name) typedef DECL_ARRAY(type) name;
187 
188 #define ARRAY_INIT(array) \
189  do { \
190  (array).i_alloc = 0; \
191  (array).i_size = 0; \
192  (array).p_elems = NULL; \
193  } while(0)
194 
195 #define ARRAY_RESET(array) \
196  do { \
197  (array).i_alloc = 0; \
198  (array).i_size = 0; \
199  free( (array).p_elems ); (array).p_elems = NULL; \
200  } while(0)
201 
202 #define ARRAY_APPEND(array, elem) \
203  do { \
204  _ARRAY_GROW1(array); \
205  (array).p_elems[(array).i_size] = elem; \
206  (array).i_size++; \
207  } while(0)
208 
209 #define ARRAY_INSERT(array,elem,pos) \
210  do { \
211  _ARRAY_GROW1(array); \
212  if( (array).i_size - (pos) ) { \
213  memmove( (array).p_elems + (pos) + 1, (array).p_elems + (pos), \
214  ((array).i_size-(pos)) * sizeof(*(array).p_elems) ); \
215  } \
216  (array).p_elems[pos] = elem; \
217  (array).i_size++; \
218  } while(0)
219 
220 #define _ARRAY_SHRINK(array) { \
221  if( (array).i_size > 10 && (array).i_size < (int)((array).i_alloc / 1.5) ) { \
222  _ARRAY_ALLOC(array, (array).i_size + 5); \
223  } \
224 }
225 
226 #define ARRAY_FIND(array, p, idx) \
227  TAB_FIND((array).i_size, (array).p_elems, p, idx)
228 
229 #define ARRAY_REMOVE(array,pos) \
230  do { \
231  if( (array).i_size - (pos) - 1 ) \
232  { \
233  memmove( (array).p_elems + (pos), (array).p_elems + (pos) + 1, \
234  ( (array).i_size - (pos) - 1 ) *sizeof(*(array).p_elems) );\
235  } \
236  (array).i_size--; \
237  _ARRAY_SHRINK(array); \
238  } while(0)
239 
240 #define ARRAY_VAL(array, pos) array.p_elems[pos]
241 
242 #define ARRAY_BSEARCH(array, elem, zetype, key, answer) \
243  BSEARCH( (array).p_elems, (array).i_size, elem, zetype, key, answer)
244 
245 /* append ##item to index variable name to avoid variable shadowing warnings for
246  * nested loops */
247 #define ARRAY_FOREACH(item, array) \
248  for (int array_index_##item = 0; \
249  array_index_##item < (array).i_size && \
250  ((item) = (array).p_elems[array_index_##item], 1); \
251  ++array_index_##item)
252 
253 
254 /************************************************************************
255  * Dynamic arrays with progressive allocation (Preferred API)
256  ************************************************************************/
257 typedef struct vlc_array_t
258 {
259  size_t i_count;
260  void ** pp_elems;
261 } vlc_array_t;
262 
263 static inline void vlc_array_init( vlc_array_t * p_array )
264 {
265  p_array->i_count = 0;
266  p_array->pp_elems = NULL;
267 }
268 
269 static inline void vlc_array_clear( vlc_array_t * p_array )
270 {
271  free( p_array->pp_elems );
272  vlc_array_init( p_array );
273 }
274 
275 /* Read */
276 static inline size_t vlc_array_count( vlc_array_t * p_array )
277 {
278  return p_array->i_count;
279 }
280 
281 #ifndef __cplusplus
282 # define vlc_array_item_at_index(ar, idx) \
283  _Generic((ar), \
284  const vlc_array_t *: ((ar)->pp_elems[idx]), \
285  vlc_array_t *: ((ar)->pp_elems[idx]))
286 #else
287 static inline void *vlc_array_item_at_index( vlc_array_t *ar, size_t idx )
288 {
289  return ar->pp_elems[idx];
290 }
291 
292 static inline const void *vlc_array_item_at_index( const vlc_array_t *ar,
293  size_t idx )
294 {
295  return ar->pp_elems[idx];
296 }
297 #endif
298 
299 static inline ssize_t vlc_array_index_of_item( const vlc_array_t *ar,
300  const void *elem )
301 {
302  for( size_t i = 0; i < ar->i_count; i++ )
303  {
304  if( ar->pp_elems[i] == elem )
305  return i;
306  }
307  return -1;
308 }
309 
310 /* Write */
311 static inline int vlc_array_insert( vlc_array_t *ar, void *elem, int idx )
312 {
313  void **pp = (void **)realloc( ar->pp_elems,
314  sizeof( void * ) * (ar->i_count + 1) );
315  if( unlikely(pp == NULL) )
316  return -1;
317 
318  size_t tail = ar->i_count - idx;
319  if( tail > 0 )
320  memmove( pp + idx + 1, pp + idx, sizeof( void * ) * tail );
321 
322  pp[idx] = elem;
323  ar->i_count++;
324  ar->pp_elems = pp;
325  return 0;
326 }
327 
328 static inline void vlc_array_insert_or_abort( vlc_array_t *ar, void *elem, int idx )
329 {
330  if( vlc_array_insert( ar, elem, idx ) )
331  abort();
332 }
333 
334 static inline int vlc_array_append( vlc_array_t *ar, void *elem )
335 {
336  void **pp = (void **)realloc( ar->pp_elems,
337  sizeof( void * ) * (ar->i_count + 1) );
338  if( unlikely(pp == NULL) )
339  return -1;
340 
341  pp[ar->i_count++] = elem;
342  ar->pp_elems = pp;
343  return 0;
344 }
345 
346 static inline void vlc_array_append_or_abort( vlc_array_t *ar, void *elem )
347 {
348  if( vlc_array_append( ar, elem ) != 0 )
349  abort();
350 }
351 
352 static inline void vlc_array_remove( vlc_array_t *ar, size_t idx )
353 {
354  void **pp = ar->pp_elems;
355  size_t tail = ar->i_count - idx - 1;
356 
357  if( tail > 0 )
358  memmove( pp + idx, pp + idx + 1, sizeof( void * ) * tail );
359 
360  ar->i_count--;
361 
362  if( ar->i_count > 0 )
363  {
364  pp = (void **)realloc( pp, sizeof( void * ) * ar->i_count );
365  if( likely(pp != NULL) )
366  ar->pp_elems = pp;
367  }
368  else
369  {
370  free( pp );
371  ar->pp_elems = NULL;
372  }
373 }
374 
375 
376 /************************************************************************
377  * Dictionaries
378  ************************************************************************/
379 
380 /* This function is not intended to be crypto-secure, we only want it to be
381  * fast and not suck too much. This one is pretty fast and did 0 collisions
382  * in wenglish's dictionary.
383  */
384 static inline uint64_t DictHash( const char *psz_string, int hashsize )
385 {
386  uint64_t i_hash = 0;
387  if( psz_string )
388  {
389  while( *psz_string )
390  {
391  i_hash += *psz_string++;
392  i_hash += i_hash << 10;
393  i_hash ^= i_hash >> 8;
394  }
395  }
396  return i_hash % hashsize;
397 }
398 
399 typedef struct vlc_dictionary_entry_t
400 {
401  char * psz_key;
402  void * p_value;
405 
406 typedef struct vlc_dictionary_t
407 {
408  int i_size;
411 
412 static void * const kVLCDictionaryNotFound = NULL;
413 
414 static inline void vlc_dictionary_init( vlc_dictionary_t * p_dict, int i_size )
415 {
416  p_dict->p_entries = NULL;
417 
418  if( i_size > 0 )
419  {
420  p_dict->p_entries = (vlc_dictionary_entry_t **)calloc( i_size, sizeof(*p_dict->p_entries) );
421  if( !p_dict->p_entries )
422  i_size = 0;
423  }
424  p_dict->i_size = i_size;
425 }
426 
427 static inline void vlc_dictionary_clear( vlc_dictionary_t * p_dict,
428  void ( * pf_free )( void * p_data, void * p_obj ),
429  void * p_obj )
430 {
431  if( p_dict->p_entries )
432  {
433  for( int i = 0; i < p_dict->i_size; i++ )
434  {
435  vlc_dictionary_entry_t * p_current, * p_next;
436  p_current = p_dict->p_entries[i];
437  while( p_current )
438  {
439  p_next = p_current->p_next;
440  if( pf_free != NULL )
441  ( * pf_free )( p_current->p_value, p_obj );
442  free( p_current->psz_key );
443  free( p_current );
444  p_current = p_next;
445  }
446  }
447  free( p_dict->p_entries );
448  p_dict->p_entries = NULL;
449  }
450  p_dict->i_size = 0;
451 }
452 
453 static inline int
454 vlc_dictionary_has_key( const vlc_dictionary_t * p_dict, const char * psz_key )
455 {
456  if( !p_dict->p_entries )
457  return 0;
458 
459  int i_pos = DictHash( psz_key, p_dict->i_size );
460  const vlc_dictionary_entry_t * p_entry = p_dict->p_entries[i_pos];
461  for( ; p_entry != NULL; p_entry = p_entry->p_next )
462  {
463  if( !strcmp( psz_key, p_entry->psz_key ) )
464  break;
465  }
466  return p_entry != NULL;
467 }
468 
469 static inline void *
470 vlc_dictionary_value_for_key( const vlc_dictionary_t * p_dict, const char * psz_key )
471 {
472  if( !p_dict->p_entries )
473  return kVLCDictionaryNotFound;
474 
475  int i_pos = DictHash( psz_key, p_dict->i_size );
476  vlc_dictionary_entry_t * p_entry = p_dict->p_entries[i_pos];
477 
478  if( !p_entry )
479  return kVLCDictionaryNotFound;
480 
481  /* Make sure we return the right item. (Hash collision) */
482  do {
483  if( !strcmp( psz_key, p_entry->psz_key ) )
484  return p_entry->p_value;
485  p_entry = p_entry->p_next;
486  } while( p_entry );
487 
488  return kVLCDictionaryNotFound;
489 }
490 
491 static inline int
493 {
494  vlc_dictionary_entry_t * p_entry;
495  int i, count = 0;
496 
497  if( !p_dict->p_entries )
498  return 0;
499 
500  for( i = 0; i < p_dict->i_size; i++ )
501  {
502  for( p_entry = p_dict->p_entries[i]; p_entry; p_entry = p_entry->p_next ) count++;
503  }
504  return count;
505 }
506 
507 static inline bool
509 {
510  if( p_dict->p_entries )
511  for( int i = 0; i < p_dict->i_size; i++ )
512  if( p_dict->p_entries[i] )
513  return false;
514  return true;
515 }
516 
517 static inline char **
519 {
520  vlc_dictionary_entry_t * p_entry;
521  char ** ppsz_ret;
522  int i, count = vlc_dictionary_keys_count( p_dict );
523 
524  ppsz_ret = (char**)malloc(sizeof(char *) * (count + 1));
525  if( unlikely(!ppsz_ret) )
526  return NULL;
527 
528  count = 0;
529  for( i = 0; i < p_dict->i_size; i++ )
530  {
531  for( p_entry = p_dict->p_entries[i]; p_entry; p_entry = p_entry->p_next )
532  ppsz_ret[count++] = strdup( p_entry->psz_key );
533  }
534  ppsz_ret[count] = NULL;
535  return ppsz_ret;
536 }
537 
538 static inline void
539 vlc_dictionary_insert_impl_( vlc_dictionary_t * p_dict, const char * psz_key,
540  void * p_value, bool rebuild )
541 {
542  if( !p_dict->p_entries )
543  vlc_dictionary_init( p_dict, 1 );
544 
545  int i_pos = DictHash( psz_key, p_dict->i_size );
546  vlc_dictionary_entry_t * p_entry;
547 
548  p_entry = (vlc_dictionary_entry_t *)malloc(sizeof(*p_entry));
549  p_entry->psz_key = strdup( psz_key );
550  p_entry->p_value = p_value;
551  p_entry->p_next = p_dict->p_entries[i_pos];
552  p_dict->p_entries[i_pos] = p_entry;
553  if( rebuild )
554  {
555  /* Count how many items there was */
556  int count;
557  for( count = 1; p_entry->p_next; count++ )
558  p_entry = p_entry->p_next;
559  if( count > 3 ) /* XXX: this need tuning */
560  {
561  /* Here it starts to be not good, rebuild a bigger dictionary */
562  struct vlc_dictionary_t new_dict;
563  int i_new_size = ( (p_dict->i_size+2) * 3) / 2; /* XXX: this need tuning */
564  int i;
565  vlc_dictionary_init( &new_dict, i_new_size );
566  for( i = 0; i < p_dict->i_size; i++ )
567  {
568  p_entry = p_dict->p_entries[i];
569  while( p_entry )
570  {
571  vlc_dictionary_insert_impl_( &new_dict, p_entry->psz_key,
572  p_entry->p_value,
573  false /* To avoid multiple rebuild loop */);
574  p_entry = p_entry->p_next;
575  }
576  }
577 
578  vlc_dictionary_clear( p_dict, NULL, NULL );
579  p_dict->i_size = new_dict.i_size;
580  p_dict->p_entries = new_dict.p_entries;
581  }
582  }
583 }
584 
585 static inline void
586 vlc_dictionary_insert( vlc_dictionary_t * p_dict, const char * psz_key, void * p_value )
587 {
588  vlc_dictionary_insert_impl_( p_dict, psz_key, p_value, true );
589 }
590 
591 static inline void
592 vlc_dictionary_remove_value_for_key( const vlc_dictionary_t * p_dict, const char * psz_key,
593  void ( * pf_free )( void * p_data, void * p_obj ),
594  void * p_obj )
595 {
596  if( !p_dict->p_entries )
597  return;
598 
599  int i_pos = DictHash( psz_key, p_dict->i_size );
600  vlc_dictionary_entry_t * p_entry = p_dict->p_entries[i_pos];
601  vlc_dictionary_entry_t * p_prev;
602 
603  if( !p_entry )
604  return; /* Not found, nothing to do */
605 
606  /* Hash collision */
607  p_prev = NULL;
608  do {
609  if( !strcmp( psz_key, p_entry->psz_key ) )
610  {
611  if( pf_free != NULL )
612  ( * pf_free )( p_entry->p_value, p_obj );
613  if( !p_prev )
614  p_dict->p_entries[i_pos] = p_entry->p_next;
615  else
616  p_prev->p_next = p_entry->p_next;
617  free( p_entry->psz_key );
618  free( p_entry );
619  return;
620  }
621  p_prev = p_entry;
622  p_entry = p_entry->p_next;
623  } while( p_entry );
624 
625  /* No key was found */
626 }
627 
628 #ifdef __cplusplus
629 // C++ helpers
630 template <typename T>
631 void vlc_delete_all( T &container )
632 {
633  typename T::iterator it = container.begin();
634  while ( it != container.end() )
635  {
636  delete *it;
637  ++it;
638  }
639  container.clear();
640 }
641 
642 #endif
643 
644 #endif
vlc_dictionary_insert
static void vlc_dictionary_insert(vlc_dictionary_t *p_dict, const char *psz_key, void *p_value)
Definition: vlc_arrays.h:587
vlc_array_append_or_abort
static void vlc_array_append_or_abort(vlc_array_t *ar, void *elem)
Definition: vlc_arrays.h:347
vlc_dictionary_t::i_size
int i_size
Definition: vlc_arrays.h:409
count
size_t count
Definition: core.c:401
vlc_dictionary_entry_t::p_next
struct vlc_dictionary_entry_t * p_next
Definition: vlc_arrays.h:404
vlc_dictionary_t::p_entries
vlc_dictionary_entry_t ** p_entries
Definition: vlc_arrays.h:410
vlc_dictionary_entry_t::p_value
void * p_value
Definition: vlc_arrays.h:403
vlc_array_insert_or_abort
static void vlc_array_insert_or_abort(vlc_array_t *ar, void *elem, int idx)
Definition: vlc_arrays.h:329
vlc_array_remove
static void vlc_array_remove(vlc_array_t *ar, size_t idx)
Definition: vlc_arrays.h:353
unlikely
#define unlikely(p)
Predicted false condition.
Definition: vlc_common.h:227
vlc_common.h
vlc_array_t::i_count
size_t i_count
Definition: vlc_arrays.h:262
vlc_dictionary_keys_count
static int vlc_dictionary_keys_count(const vlc_dictionary_t *p_dict)
Definition: vlc_arrays.h:493
vlc_dictionary_t
Definition: vlc_arrays.h:407
realloc_down
static void * realloc_down(void *ptr, size_t size)
Definition: vlc_arrays.h:34
vlc_dictionary_clear
static void vlc_dictionary_clear(vlc_dictionary_t *p_dict, void(*pf_free)(void *p_data, void *p_obj), void *p_obj)
Definition: vlc_arrays.h:428
vlc_dictionary_insert_impl_
static void vlc_dictionary_insert_impl_(vlc_dictionary_t *p_dict, const char *psz_key, void *p_value, bool rebuild)
Definition: vlc_arrays.h:540
vlc_array_append
static int vlc_array_append(vlc_array_t *ar, void *elem)
Definition: vlc_arrays.h:335
vlc_array_insert
static int vlc_array_insert(vlc_array_t *ar, void *elem, int idx)
Definition: vlc_arrays.h:312
vlc_array_t
struct vlc_array_t vlc_array_t
vlc_dictionary_entry_t
Definition: vlc_arrays.h:400
vlc_dictionary_is_empty
static bool vlc_dictionary_is_empty(const vlc_dictionary_t *p_dict)
Definition: vlc_arrays.h:509
DictHash
static uint64_t DictHash(const char *psz_string, int hashsize)
Definition: vlc_arrays.h:385
vlc_array_t
Definition: vlc_arrays.h:258
vlc_dictionary_entry_t::psz_key
char * psz_key
Definition: vlc_arrays.h:402
vlc_array_count
static size_t vlc_array_count(vlc_array_t *p_array)
Definition: vlc_arrays.h:277
vlc_dictionary_all_keys
static char ** vlc_dictionary_all_keys(const vlc_dictionary_t *p_dict)
Definition: vlc_arrays.h:519
vlc_dictionary_value_for_key
static void * vlc_dictionary_value_for_key(const vlc_dictionary_t *p_dict, const char *psz_key)
Definition: vlc_arrays.h:471
vlc_dictionary_t
struct vlc_dictionary_t vlc_dictionary_t
vlc_dictionary_has_key
static int vlc_dictionary_has_key(const vlc_dictionary_t *p_dict, const char *psz_key)
Definition: vlc_arrays.h:455
vlc_array_init
static void vlc_array_init(vlc_array_t *p_array)
Definition: vlc_arrays.h:264
vlc_array_clear
static void vlc_array_clear(vlc_array_t *p_array)
Definition: vlc_arrays.h:270
strdup
char * strdup(const char *)
vlc_dictionary_entry_t
struct vlc_dictionary_entry_t vlc_dictionary_entry_t
vlc_array_item_at_index
#define vlc_array_item_at_index(ar, idx)
Definition: vlc_arrays.h:283
kVLCDictionaryNotFound
static void *const kVLCDictionaryNotFound
Definition: vlc_arrays.h:413
vlc_dictionary_init
static void vlc_dictionary_init(vlc_dictionary_t *p_dict, int i_size)
Definition: vlc_arrays.h:415
likely
#define likely(p)
Predicted true condition.
Definition: vlc_common.h:218
vlc_array_t::pp_elems
void ** pp_elems
Definition: vlc_arrays.h:263
realloc_or_free
static void * realloc_or_free(void *p, size_t sz)
This wrapper around realloc() will free the input pointer when realloc() returns NULL.
Definition: vlc_arrays.h:47
vlc_dictionary_remove_value_for_key
static void vlc_dictionary_remove_value_for_key(const vlc_dictionary_t *p_dict, const char *psz_key, void(*pf_free)(void *p_data, void *p_obj), void *p_obj)
Definition: vlc_arrays.h:593
vlc_array_index_of_item
static ssize_t vlc_array_index_of_item(const vlc_array_t *ar, const void *elem)
Definition: vlc_arrays.h:300
p
#define p(t)