@@ -197,13 +197,24 @@ static struct stored_bitmap *store_bitmap(struct bitmap_index *index,
197197 return stored ;
198198}
199199
200+ static inline uint32_t read_be32 (const unsigned char * buffer , size_t * pos )
201+ {
202+ uint32_t result = get_be32 (buffer + * pos );
203+ (* pos ) += sizeof (result );
204+ return result ;
205+ }
206+
207+ static inline uint8_t read_u8 (const unsigned char * buffer , size_t * pos )
208+ {
209+ return buffer [(* pos )++ ];
210+ }
211+
200212static int load_bitmap_entries_v1 (struct bitmap_index * index )
201213{
202214 static const size_t MAX_XOR_OFFSET = 160 ;
203215
204216 uint32_t i ;
205217 struct stored_bitmap * * recent_bitmaps ;
206- struct bitmap_disk_entry * entry ;
207218
208219 recent_bitmaps = xcalloc (MAX_XOR_OFFSET , sizeof (struct stored_bitmap ));
209220
@@ -214,15 +225,12 @@ static int load_bitmap_entries_v1(struct bitmap_index *index)
214225 uint32_t commit_idx_pos ;
215226 const unsigned char * sha1 ;
216227
217- entry = (struct bitmap_disk_entry * )(index -> map + index -> map_pos );
218- index -> map_pos += sizeof (struct bitmap_disk_entry );
228+ commit_idx_pos = read_be32 (index -> map , & index -> map_pos );
229+ xor_offset = read_u8 (index -> map , & index -> map_pos );
230+ flags = read_u8 (index -> map , & index -> map_pos );
219231
220- commit_idx_pos = ntohl (entry -> object_pos );
221232 sha1 = nth_packed_object_sha1 (index -> pack , commit_idx_pos );
222233
223- xor_offset = (int )entry -> xor_offset ;
224- flags = (int )entry -> flags ;
225-
226234 bitmap = read_bitmap_1 (index );
227235 if (!bitmap )
228236 return -1 ;
0 commit comments