@@ -536,23 +536,25 @@ void wfp_invert(uint32_t wfpint32, uint8_t *out)
536536static void matchmap_setup (scan_data_t * scan )
537537{
538538 char * matchmap_env = getenv ("SCANOSS_MATCHMAP_MAX" );
539+ scan -> max_matchmap_size = DEFAULT_MATCHMAP_FILES ;
539540 if (matchmap_env )
540541 {
541542 int matchmap_max_files_aux = atoi (matchmap_env );
542543 if (matchmap_max_files_aux > DEFAULT_MATCHMAP_FILES / 4 && matchmap_max_files_aux < DEFAULT_MATCHMAP_FILES * 20 )
543544 {
544545 scanlog ("matchmap size changed by env variable to: %d\n" , matchmap_max_files_aux );
545- matchmap_max_files = matchmap_max_files_aux ;
546+ scan -> max_matchmap_size = matchmap_max_files_aux ;
546547 }
547548 }
548549 //If we are looking fow multiple snippets, update the matchmap size
549- matchmap_max_files = scan -> max_snippets_to_process * matchmap_max_files ;
550+ scan -> max_matchmap_size * = scan -> max_snippets_to_process ;
550551
551552 if (engine_flags & ENABLE_HIGH_ACCURACY )
552553 {
553- matchmap_max_files *=5 ;
554- scanlog ("matchmap size changed by high accuracy analisys to: %d\n" , matchmap_max_files );
554+ scan -> max_matchmap_size *=5 ;
555+ scanlog ("matchmap size changed by high accuracy analisys to: %d\n" , scan -> max_matchmap_size );
555556 }
557+ matchmap_max_files = scan -> max_matchmap_size ;
556558}
557559
558560typedef struct matchmap_entry_t
@@ -581,7 +583,7 @@ int add_file_to_matchmap(scan_data_t *scan, matchmap_entry_t *item, uint8_t *md5
581583 for (long t = start_pos ; t < scan -> matchmap_size ; t ++ )
582584 {
583585 //The matchmap is sorted, stop if you are comparing against a different sector
584- if (* scan -> matchmap [t ].md5 > * md5 && (scan -> matchmap_size < matchmap_max_files ))
586+ if (* scan -> matchmap [t ].md5 > * md5 && (scan -> matchmap_size < scan -> max_matchmap_size ))
585587 {
586588 scanlog ("skipping: md5 out of range wfp\n" );
587589 return -1 ;
@@ -614,7 +616,7 @@ int add_file_to_matchmap(scan_data_t *scan, matchmap_entry_t *item, uint8_t *md5
614616 if (found < 0 )
615617 {
616618 /* Not found. Add MD5 to map */
617- if (scan -> matchmap_size >= matchmap_max_files )
619+ if (scan -> matchmap_size >= scan -> max_matchmap_size )
618620 {
619621 scanlog ("skipping: matchmap is full\n" );
620622 return -1 ;
@@ -704,11 +706,6 @@ match_t ldb_scan_snippets(scan_data_t *scan)
704706 if (engine_flags & DISABLE_SNIPPET_MATCHING )
705707 return MATCH_NONE ;
706708
707- if (trace_on )
708- scanlog ("Checking snippets. Traced (-qi) matches marked with *\n" );
709- else
710- scanlog ("Checking snippets\n" );
711-
712709 matchmap_setup (scan );
713710 adjust_tolerance (scan );
714711
@@ -753,7 +750,7 @@ match_t ldb_scan_snippets(scan_data_t *scan)
753750 memset (map_indirection_index , 0 , sizeof (map_indirection_index ));
754751
755752 scanlog ("< Snippet scan setup: Total lines: %d ,Matchmap size: %d, Min hits: %d, Min lines: %d, Map max size = %d, Cat N = %d x %d, Cat size = %d >\n" ,
756- scan -> total_lines , matchmap_max_files , min_match_hits , min_match_lines , map_max_size , MAP_INDIRECTION_CAT_NUMBER , map_indedirection_items_size , MAP_INDIRECTION_CAT_SIZE );
753+ scan -> total_lines , scan -> max_matchmap_size , min_match_hits , min_match_lines , map_max_size , MAP_INDIRECTION_CAT_NUMBER , map_indedirection_items_size , MAP_INDIRECTION_CAT_SIZE );
757754
758755 for (int i = 0 ; i < scan -> hash_count ; i ++ )
759756 {
@@ -802,11 +799,11 @@ match_t ldb_scan_snippets(scan_data_t *scan)
802799 map_lines_indirection [map [map_indirection [i ][j ]].line ] = 1 ;
803800 lines_coverage ++ ;
804801 }
805- if (cat_limit > matchmap_max_files )
802+ if (cat_limit > scan -> max_matchmap_size )
806803 {
807804 if ((hashes_to_process < scan -> hash_count / 10 || (float ) lines_coverage / scan -> hash_count < 0.6 ) && cat_limit < MAX_MATCHMAP_FILES )
808805 {
809- matchmap_max_files += map [map_indirection [i ][j ]].size ;
806+ scan -> max_matchmap_size += map [map_indirection [i ][j ]].size ;
810807 }
811808 else
812809 {
@@ -843,10 +840,10 @@ match_t ldb_scan_snippets(scan_data_t *scan)
843840 }
844841 }
845842 }
846- matchmap_max_files = cat_limit ;
843+ scan -> max_matchmap_size = cat_limit ;
847844 scanlog ("Map limit on %d MD5s at %d of %d caths. Selected hashes: %d/%d - lines coverage %d\n" ,
848- matchmap_max_files , cat_limit_index , MAP_INDIRECTION_CAT_NUMBER , hashes_to_process , scan -> hash_count , (lines_coverage * 100 ) / scan -> total_lines );
849- scan -> matchmap = calloc (matchmap_max_files , sizeof (matchmap_entry ));
845+ scan -> max_matchmap_size , cat_limit_index , MAP_INDIRECTION_CAT_NUMBER , hashes_to_process , scan -> hash_count , (lines_coverage * 100 ) / scan -> total_lines );
846+ scan -> matchmap = calloc (scan -> max_matchmap_size , sizeof (matchmap_entry ));
850847
851848 int map_indexes [scan -> hash_count ];
852849 memset (map_indexes , 0 , sizeof (map_indexes ));
0 commit comments