@@ -458,6 +458,9 @@ struct write_midx_context {
458
458
struct multi_pack_index * m ;
459
459
struct progress * progress ;
460
460
unsigned pack_paths_checked ;
461
+
462
+ struct pack_midx_entry * entries ;
463
+ uint32_t entries_nr ;
461
464
};
462
465
463
466
static void add_pack_to_midx (const char * full_path , size_t full_path_len ,
@@ -678,11 +681,11 @@ static size_t write_midx_pack_names(struct hashfile *f, void *data)
678
681
}
679
682
680
683
static size_t write_midx_oid_fanout (struct hashfile * f ,
681
- struct pack_midx_entry * objects ,
682
- uint32_t nr_objects )
684
+ void * data )
683
685
{
684
- struct pack_midx_entry * list = objects ;
685
- struct pack_midx_entry * last = objects + nr_objects ;
686
+ struct write_midx_context * ctx = data ;
687
+ struct pack_midx_entry * list = ctx -> entries ;
688
+ struct pack_midx_entry * last = ctx -> entries + ctx -> entries_nr ;
686
689
uint32_t count = 0 ;
687
690
uint32_t i ;
688
691
@@ -706,18 +709,19 @@ static size_t write_midx_oid_fanout(struct hashfile *f,
706
709
return MIDX_CHUNK_FANOUT_SIZE ;
707
710
}
708
711
709
- static size_t write_midx_oid_lookup (struct hashfile * f , unsigned char hash_len ,
710
- struct pack_midx_entry * objects ,
711
- uint32_t nr_objects )
712
+ static size_t write_midx_oid_lookup (struct hashfile * f ,
713
+ void * data )
712
714
{
713
- struct pack_midx_entry * list = objects ;
715
+ struct write_midx_context * ctx = data ;
716
+ unsigned char hash_len = the_hash_algo -> rawsz ;
717
+ struct pack_midx_entry * list = ctx -> entries ;
714
718
uint32_t i ;
715
719
size_t written = 0 ;
716
720
717
- for (i = 0 ; i < nr_objects ; i ++ ) {
721
+ for (i = 0 ; i < ctx -> entries_nr ; i ++ ) {
718
722
struct pack_midx_entry * obj = list ++ ;
719
723
720
- if (i < nr_objects - 1 ) {
724
+ if (i < ctx -> entries_nr - 1 ) {
721
725
struct pack_midx_entry * next = list ;
722
726
if (oidcmp (& obj -> oid , & next -> oid ) >= 0 )
723
727
BUG ("OIDs not in order: %s >= %s" ,
@@ -805,8 +809,7 @@ static int write_midx_internal(const char *object_dir, struct multi_pack_index *
805
809
uint64_t written = 0 ;
806
810
uint32_t chunk_ids [MIDX_MAX_CHUNKS + 1 ];
807
811
uint64_t chunk_offsets [MIDX_MAX_CHUNKS + 1 ];
808
- uint32_t nr_entries , num_large_offsets = 0 ;
809
- struct pack_midx_entry * entries = NULL ;
812
+ uint32_t num_large_offsets = 0 ;
810
813
struct progress * progress = NULL ;
811
814
int large_offsets_needed = 0 ;
812
815
int pack_name_concat_len = 0 ;
@@ -852,12 +855,12 @@ static int write_midx_internal(const char *object_dir, struct multi_pack_index *
852
855
if (ctx .m && ctx .nr == ctx .m -> num_packs && !packs_to_drop )
853
856
goto cleanup ;
854
857
855
- entries = get_sorted_entries (ctx .m , ctx .info , ctx .nr , & nr_entries );
858
+ ctx . entries = get_sorted_entries (ctx .m , ctx .info , ctx .nr , & ctx . entries_nr );
856
859
857
- for (i = 0 ; i < nr_entries ; i ++ ) {
858
- if (entries [i ].offset > 0x7fffffff )
860
+ for (i = 0 ; i < ctx . entries_nr ; i ++ ) {
861
+ if (ctx . entries [i ].offset > 0x7fffffff )
859
862
num_large_offsets ++ ;
860
- if (entries [i ].offset > 0xffffffff )
863
+ if (ctx . entries [i ].offset > 0xffffffff )
861
864
large_offsets_needed = 1 ;
862
865
}
863
866
@@ -947,10 +950,10 @@ static int write_midx_internal(const char *object_dir, struct multi_pack_index *
947
950
948
951
cur_chunk ++ ;
949
952
chunk_ids [cur_chunk ] = MIDX_CHUNKID_OBJECTOFFSETS ;
950
- chunk_offsets [cur_chunk ] = chunk_offsets [cur_chunk - 1 ] + nr_entries * the_hash_algo -> rawsz ;
953
+ chunk_offsets [cur_chunk ] = chunk_offsets [cur_chunk - 1 ] + ctx . entries_nr * the_hash_algo -> rawsz ;
951
954
952
955
cur_chunk ++ ;
953
- chunk_offsets [cur_chunk ] = chunk_offsets [cur_chunk - 1 ] + nr_entries * MIDX_CHUNK_OFFSET_WIDTH ;
956
+ chunk_offsets [cur_chunk ] = chunk_offsets [cur_chunk - 1 ] + ctx . entries_nr * MIDX_CHUNK_OFFSET_WIDTH ;
954
957
if (large_offsets_needed ) {
955
958
chunk_ids [cur_chunk ] = MIDX_CHUNKID_LARGEOFFSETS ;
956
959
@@ -993,19 +996,19 @@ static int write_midx_internal(const char *object_dir, struct multi_pack_index *
993
996
break ;
994
997
995
998
case MIDX_CHUNKID_OIDFANOUT :
996
- written += write_midx_oid_fanout (f , entries , nr_entries );
999
+ written += write_midx_oid_fanout (f , & ctx );
997
1000
break ;
998
1001
999
1002
case MIDX_CHUNKID_OIDLOOKUP :
1000
- written += write_midx_oid_lookup (f , the_hash_algo -> rawsz , entries , nr_entries );
1003
+ written += write_midx_oid_lookup (f , & ctx );
1001
1004
break ;
1002
1005
1003
1006
case MIDX_CHUNKID_OBJECTOFFSETS :
1004
- written += write_midx_object_offsets (f , large_offsets_needed , pack_perm , entries , nr_entries );
1007
+ written += write_midx_object_offsets (f , large_offsets_needed , pack_perm , ctx . entries , ctx . entries_nr );
1005
1008
break ;
1006
1009
1007
1010
case MIDX_CHUNKID_LARGEOFFSETS :
1008
- written += write_midx_large_offsets (f , num_large_offsets , entries , nr_entries );
1011
+ written += write_midx_large_offsets (f , num_large_offsets , ctx . entries , ctx . entries_nr );
1009
1012
break ;
1010
1013
1011
1014
default :
@@ -1035,7 +1038,7 @@ static int write_midx_internal(const char *object_dir, struct multi_pack_index *
1035
1038
}
1036
1039
1037
1040
free (ctx .info );
1038
- free (entries );
1041
+ free (ctx . entries );
1039
1042
free (pack_perm );
1040
1043
free (midx_name );
1041
1044
return result ;
0 commit comments