Changeset 14d79cf6826d44fbf594593b7d5db7da01cc88b0

Show
Ignore:
Timestamp:
15/02/08 23:04:18 (10 months ago)
Author:
Pierre d'Herbemont <pdherbemont@videolan.org>
git-committer:
Pierre d'Herbemont <pdherbemont@videolan.org> 1203113058 +0000
git-parent:

[456bdd9fa8cd8bd665a1c7f0d9a71a6b87bb7efc]

git-author:
Pierre d'Herbemont <pdherbemont@videolan.org> 1203113058 +0000
Message:

vlc_arrays.h: Fix insertion rebuilding.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • include/vlc_arrays.h

    r5363868 r14d79cf  
    439439            while( p_current ) 
    440440            { 
    441                 p_next = p_dict->p_entries[i]->p_next; 
    442                 free( p_dict->p_entries[i]->psz_key ); 
     441                p_next = p_current->p_next; 
     442                free( p_current->psz_key ); 
    443443                free( p_current ); 
    444444                p_current = p_next; 
     
    463463    if( !p_entry ) 
    464464        return kVLCDictionaryNotFound; 
    465  
    466     if( p_entry && !p_entry->p_next ) 
    467         return p_entry->p_value; 
    468465 
    469466    /* Make sure we return the right item. (Hash collision) */ 
     
    524521 
    525522    int i_pos = DictHash( psz_key, p_dict->i_size ); 
    526     struct vlc_dictionary_entry_t * p_entry = p_dict->p_entries[i_pos]; 
    527  
    528     if( !p_entry ) 
    529     { 
    530         p_entry = p_dict->p_entries[i_pos] = (struct vlc_dictionary_entry_t *)malloc( 
    531                 sizeof(struct vlc_dictionary_entry_t)); 
    532         assert( p_entry ); 
    533  
    534         p_entry->psz_key = strdup( psz_key ); 
    535         assert( p_entry->psz_key ); 
    536         p_entry->p_value = p_value; 
    537         p_dict->p_entries[i_pos]->p_next = NULL; 
    538         return; 
    539     } 
    540     if( p_entry->p_value == kVLCDictionaryNotFound ) 
    541     { 
    542         /* This one is fine, just high jack */ 
    543         p_entry->psz_key = strdup( psz_key ); 
    544         p_entry->p_value = p_value; 
    545         return; 
    546     } 
    547  
    548     /* Hash collision here */ 
     523    struct vlc_dictionary_entry_t * p_entry; 
     524 
    549525    p_entry = (struct vlc_dictionary_entry_t *)malloc(sizeof(struct vlc_dictionary_entry_t)); 
    550526    assert( p_entry ); 
     
    553529    p_entry->p_next = p_dict->p_entries[i_pos]; 
    554530    p_dict->p_entries[i_pos] = p_entry; 
    555  
    556531    if( rebuild ) 
    557532    { 
     
    565540            int i_new_size = ( (p_dict->i_size+2) * 3) / 2; /* XXX: this need tuning */ 
    566541            int i; 
    567  
    568542            vlc_dictionary_init( &new_dict, i_new_size ); 
    569543            for( i = 0; i < p_dict->i_size; i++ ) 
    570544            { 
    571545                p_entry = p_dict->p_entries[i]; 
    572                 while( p_entry ); 
     546                while( p_entry ) 
    573547                { 
    574548                    __vlc_dictionary_insert( &new_dict, p_entry->psz_key, 
     
    578552                } 
    579553            } 
     554 
    580555            vlc_dictionary_clear( p_dict ); 
    581556            p_dict->i_size = new_dict.i_size; 
     
    603578    if( !p_entry ) 
    604579        return; /* Not found, nothing to do */ 
    605  
    606     if( !p_entry->p_next ) 
    607     { 
    608         free( p_entry->psz_key ); 
    609         free( p_entry ); 
    610         p_dict->p_entries[i_pos] = NULL; 
    611         return; 
    612     } 
    613580 
    614581    /* Hash collision */