Browse Source

vlc_arrays: use size_t for dictionaries

pull/177/head
Alexandre Janniaux 5 years ago
committed by Felix Paul Kühne
parent
commit
1ff33faabc
  1. 18
      include/vlc_arrays.h
  2. 2
      modules/codec/ttml/genttml.c
  3. 8
      modules/codec/ttml/substtml.c
  4. 2
      modules/demux/mpeg/ts.c

18
include/vlc_arrays.h

@ -405,13 +405,13 @@ typedef struct vlc_dictionary_entry_t
typedef struct vlc_dictionary_t
{
int i_size;
size_t i_size;
vlc_dictionary_entry_t ** p_entries;
} vlc_dictionary_t;
static void * const kVLCDictionaryNotFound = NULL;
static inline void vlc_dictionary_init( vlc_dictionary_t * p_dict, int i_size )
static inline void vlc_dictionary_init(vlc_dictionary_t * p_dict, size_t i_size)
{
p_dict->p_entries = NULL;
@ -430,7 +430,7 @@ static inline void vlc_dictionary_clear( vlc_dictionary_t * p_dict,
{
if( p_dict->p_entries )
{
for( int i = 0; i < p_dict->i_size; i++ )
for (size_t i = 0; i < p_dict->i_size; i++)
{
vlc_dictionary_entry_t * p_current, * p_next;
p_current = p_dict->p_entries[i];
@ -488,11 +488,11 @@ vlc_dictionary_value_for_key( const vlc_dictionary_t * p_dict, const char * psz_
return kVLCDictionaryNotFound;
}
static inline int
static inline size_t
vlc_dictionary_keys_count( const vlc_dictionary_t * p_dict )
{
vlc_dictionary_entry_t * p_entry;
int i, count = 0;
size_t i, count = 0;
if( !p_dict->p_entries )
return 0;
@ -508,7 +508,7 @@ static inline bool
vlc_dictionary_is_empty( const vlc_dictionary_t * p_dict )
{
if( p_dict->p_entries )
for( int i = 0; i < p_dict->i_size; i++ )
for (size_t i = 0; i < p_dict->i_size; i++)
if( p_dict->p_entries[i] )
return false;
return true;
@ -519,7 +519,7 @@ vlc_dictionary_all_keys( const vlc_dictionary_t * p_dict )
{
vlc_dictionary_entry_t * p_entry;
char ** ppsz_ret;
int i, count = vlc_dictionary_keys_count( p_dict );
size_t i, count = vlc_dictionary_keys_count(p_dict);
ppsz_ret = (char**)malloc(sizeof(char *) * (count + 1));
if( unlikely(!ppsz_ret) )
@ -560,8 +560,8 @@ vlc_dictionary_insert_impl_( vlc_dictionary_t * p_dict, const char * psz_key,
{
/* Here it starts to be not good, rebuild a bigger dictionary */
struct vlc_dictionary_t new_dict;
int i_new_size = ( (p_dict->i_size+2) * 3) / 2; /* XXX: this need tuning */
int i;
size_t i_new_size = (p_dict->i_size + 2) * 3 / 2; /* XXX: this need tuning */
size_t i;
vlc_dictionary_init( &new_dict, i_new_size );
for( i = 0; i < p_dict->i_size; i++ )
{

2
modules/codec/ttml/genttml.c

@ -89,7 +89,7 @@ void tt_node_AttributesToText( struct vlc_memstream *p_stream, const tt_node_t*
{
bool b_timed_node = false;
const vlc_dictionary_t* p_attr_dict = &p_node->attr_dict;
for( int i = 0; i < p_attr_dict->i_size; ++i )
for (size_t i = 0; i < p_attr_dict->i_size; ++i)
{
for ( vlc_dictionary_entry_t* p_entry = p_attr_dict->p_entries[i];
p_entry != NULL; p_entry = p_entry->p_next )

8
modules/codec/ttml/substtml.c

@ -584,7 +584,7 @@ static void FillTTMLStyle( const char *psz_attr, const char *psz_namespace,
static void DictionaryMerge( const vlc_dictionary_t *p_src, vlc_dictionary_t *p_dst,
bool b_override )
{
for( int i = 0; i < p_src->i_size; ++i )
for (size_t i = 0; i < p_src->i_size; ++i)
{
for ( const vlc_dictionary_entry_t* p_entry = p_src->p_entries[i];
p_entry != NULL; p_entry = p_entry->p_next )
@ -677,7 +677,7 @@ static void DictToTTMLStyle( ttml_context_t *p_ctx, tt_namespaces_t *p_nss,
const vlc_dictionary_t *p_dict,
ttml_style_t *p_ttml_style )
{
for( int i = 0; i < p_dict->i_size; ++i )
for (size_t i = 0; i < p_dict->i_size; ++i)
{
for ( vlc_dictionary_entry_t* p_entry = p_dict->p_entries[i];
p_entry != NULL; p_entry = p_entry->p_next )
@ -827,7 +827,7 @@ static ttml_region_t *GetTTMLRegion( ttml_context_t *p_ctx, tt_namespaces_t *p_n
if( (p_region = ttml_region_New( false )) )
{
/* Fill from its own attributes */
for( int i = 0; i < merged.i_size; ++i )
for (size_t i = 0; i < merged.i_size; ++i)
{
for ( vlc_dictionary_entry_t* p_entry = merged.p_entries[i];
p_entry != NULL; p_entry = p_entry->p_next )
@ -1119,7 +1119,7 @@ static ttml_region_t *GenerateRegions( tt_namespaces_t *p_nss, tt_node_t *p_root
vlc_dictionary_init( &context.regions, 1 );
ConvertNodesToRegionContent( &context, p_nss, p_bodynode, NULL, NULL, playbacktime );
for( int i = 0; i < context.regions.i_size; ++i )
for (size_t i = 0; i < context.regions.i_size; ++i)
{
for ( const vlc_dictionary_entry_t* p_entry = context.regions.p_entries[i];
p_entry != NULL; p_entry = p_entry->p_next )

2
modules/demux/mpeg/ts.c

@ -1222,7 +1222,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
return VLC_EGENERIC;
*pi_int = 0;
for( int i = 0; i < p_sys->attachments.i_size; i++ )
for (size_t i = 0; i < p_sys->attachments.i_size; i++)
{
for( vlc_dictionary_entry_t *p_entry = p_sys->attachments.p_entries[i];
p_entry; p_entry = p_entry->p_next )

Loading…
Cancel
Save