Changeset 14d79cf6826d44fbf594593b7d5db7da01cc88b0
- 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
| r5363868 |
r14d79cf |
|
| 439 | 439 | while( p_current ) |
|---|
| 440 | 440 | { |
|---|
| 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 ); |
|---|
| 443 | 443 | free( p_current ); |
|---|
| 444 | 444 | p_current = p_next; |
|---|
| … | … | |
| 463 | 463 | if( !p_entry ) |
|---|
| 464 | 464 | return kVLCDictionaryNotFound; |
|---|
| 465 | | |
|---|
| 466 | | if( p_entry && !p_entry->p_next ) |
|---|
| 467 | | return p_entry->p_value; |
|---|
| 468 | 465 | |
|---|
| 469 | 466 | /* Make sure we return the right item. (Hash collision) */ |
|---|
| … | … | |
| 524 | 521 | |
|---|
| 525 | 522 | 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 | |
|---|
| 549 | 525 | p_entry = (struct vlc_dictionary_entry_t *)malloc(sizeof(struct vlc_dictionary_entry_t)); |
|---|
| 550 | 526 | assert( p_entry ); |
|---|
| … | … | |
| 553 | 529 | p_entry->p_next = p_dict->p_entries[i_pos]; |
|---|
| 554 | 530 | p_dict->p_entries[i_pos] = p_entry; |
|---|
| 555 | | |
|---|
| 556 | 531 | if( rebuild ) |
|---|
| 557 | 532 | { |
|---|
| … | … | |
| 565 | 540 | int i_new_size = ( (p_dict->i_size+2) * 3) / 2; /* XXX: this need tuning */ |
|---|
| 566 | 541 | int i; |
|---|
| 567 | | |
|---|
| 568 | 542 | vlc_dictionary_init( &new_dict, i_new_size ); |
|---|
| 569 | 543 | for( i = 0; i < p_dict->i_size; i++ ) |
|---|
| 570 | 544 | { |
|---|
| 571 | 545 | p_entry = p_dict->p_entries[i]; |
|---|
| 572 | | while( p_entry ); |
|---|
| | 546 | while( p_entry ) |
|---|
| 573 | 547 | { |
|---|
| 574 | 548 | __vlc_dictionary_insert( &new_dict, p_entry->psz_key, |
|---|
| … | … | |
| 578 | 552 | } |
|---|
| 579 | 553 | } |
|---|
| | 554 | |
|---|
| 580 | 555 | vlc_dictionary_clear( p_dict ); |
|---|
| 581 | 556 | p_dict->i_size = new_dict.i_size; |
|---|
| … | … | |
| 603 | 578 | if( !p_entry ) |
|---|
| 604 | 579 | 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 | | } |
|---|
| 613 | 580 | |
|---|
| 614 | 581 | /* Hash collision */ |
|---|