Changeset 305 for trunk/src/sh_hash.c
- Timestamp:
- Nov 13, 2010, 11:24:24 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/sh_hash.c
r294 r305 393 393 } 394 394 395 struct two_sh_file_t { 396 sh_file_t * prev; 397 sh_file_t * this; 398 }; 399 395 400 static sh_file_t * hashsearch (const char * s); 401 static int hashsearch_prev (const char * s, struct two_sh_file_t * a, int * index); 396 402 397 403 static sh_file_t * tab[TABSIZE]; … … 423 429 char hashbuf[KEYBUF_SIZE]; 424 430 int retval; 431 volatile int flag = 0; 425 432 426 433 /* -------- find the entry for the file ---------------- */ … … 449 456 sh_error_handle (level, FIL__, __LINE__, 0, 450 457 MSG_FI_MISS2, tmp, str); 458 flag = 1; 451 459 SH_FREE(tmp); 452 460 SH_FREE(str); … … 458 466 ; /* 'label at end of compound statement */ 459 467 SH_MUTEX_UNLOCK(mutex_hash); 468 460 469 return retval; 461 470 } … … 625 634 626 635 636 627 637 /********************************************************************* 628 638 * … … 646 656 SL_RET0(_("hash_unvisited")); 647 657 } 658 659 /********************************************************************* 660 * 661 * Remove a single file from the database. 662 * 663 *********************************************************************/ 664 void sh_hash_remove (const char * path) 665 { 666 struct two_sh_file_t entries; 667 int index; 668 669 SL_ENTER(_("sh_hash_remove")); 670 671 SH_MUTEX_LOCK(mutex_hash); 672 673 if ((sh.flag.reportonce == S_TRUE && sh.flag.update == S_FALSE) || 674 (S_TRUE == sh.flag.update && S_TRUE == sh_util_ask_update(path))) 675 { 676 if (0 == hashsearch_prev (path, &entries, &index)) 677 { 678 sh_file_t * p = entries.this; 679 #ifdef REPLACE_OLD 680 /* Remove the old entry 681 */ 682 if (entries.prev == p) 683 tab[index] = p->next; 684 else 685 entries.prev->next = p->next; 686 687 p = delete_db_entry(p); 688 689 goto end; 690 SL_RET0(_("sh_hash_remove")); 691 #else 692 SET_SH_FFLAG_REPORTED(p->fflags); 693 #endif 694 } 695 } 696 697 end: 698 ; /* 'label at end of compound statement' */ 699 SH_MUTEX_UNLOCK(mutex_hash); 700 701 SL_RET0(_("sh_hash_remove")); 702 } 703 648 704 649 705 /********************************************************************* … … 772 828 } 773 829 SL_RETURN( NULL, _("hashsearch")); 830 } 831 832 static int hashsearch_prev (const char * s, struct two_sh_file_t * a, int * index) 833 { 834 sh_file_t * this; 835 sh_file_t * prev = NULL; 836 837 SL_ENTER(_("hashsearch_prev")); 838 839 if (s) 840 { 841 *index = hashfunc(s); 842 843 this = tab[*index]; 844 845 prev = this; 846 847 if (this) 848 { 849 do { 850 851 if ((this->fullpath != NULL) && (0 == strcmp(s, this->fullpath))) 852 { 853 a->prev = prev; 854 a->this = this; 855 856 SL_RETURN( 0, _("hashsearch_prev")); 857 } 858 859 prev = this; 860 this = this->next; 861 862 } while(this); 863 } 864 } 865 SL_RETURN( -1, _("hashsearch")); 774 866 } 775 867 … … 2226 2318 int i; 2227 2319 SL_ENTER(_("sh_hash_set_missing")); 2320 2228 2321 i = sh_hash_set_visited_int(newname, SH_FFLAG_CHECKED); 2322 2323 if (sh.flag.checkSum != SH_CHECK_INIT) { 2324 sh_hash_remove(newname); 2325 } 2326 2229 2327 SL_RETURN(i, _("sh_hash_set_missing")); 2230 2328 }
Note:
See TracChangeset
for help on using the changeset viewer.