@@ -39,11 +39,6 @@ struct odb_read_stream {
3939 enum { z_unused , z_used , z_done , z_error } z_state ;
4040
4141 union {
42- struct {
43- char * buf ; /* from odb_read_object_info_extended() */
44- unsigned long read_ptr ;
45- } incore ;
46-
4742 struct {
4843 void * mapped ;
4944 unsigned long mapsize ;
@@ -401,22 +396,30 @@ static int open_istream_pack_non_delta(struct odb_read_stream **out,
401396 *
402397 *****************************************************************/
403398
404- static int close_istream_incore (struct odb_read_stream * st )
399+ struct odb_incore_read_stream {
400+ struct odb_read_stream base ;
401+ char * buf ; /* from odb_read_object_info_extended() */
402+ unsigned long read_ptr ;
403+ };
404+
405+ static int close_istream_incore (struct odb_read_stream * _st )
405406{
406- free (st -> u .incore .buf );
407+ struct odb_incore_read_stream * st = (struct odb_incore_read_stream * )_st ;
408+ free (st -> buf );
407409 return 0 ;
408410}
409411
410- static ssize_t read_istream_incore (struct odb_read_stream * st , char * buf , size_t sz )
412+ static ssize_t read_istream_incore (struct odb_read_stream * _st , char * buf , size_t sz )
411413{
414+ struct odb_incore_read_stream * st = (struct odb_incore_read_stream * )_st ;
412415 size_t read_size = sz ;
413- size_t remainder = st -> size - st -> u . incore . read_ptr ;
416+ size_t remainder = st -> base . size - st -> read_ptr ;
414417
415418 if (remainder <= read_size )
416419 read_size = remainder ;
417420 if (read_size ) {
418- memcpy (buf , st -> u . incore . buf + st -> u . incore . read_ptr , read_size );
419- st -> u . incore . read_ptr += read_size ;
421+ memcpy (buf , st -> buf + st -> read_ptr , read_size );
422+ st -> read_ptr += read_size ;
420423 }
421424 return read_size ;
422425}
@@ -426,22 +429,25 @@ static int open_istream_incore(struct odb_read_stream **out,
426429 const struct object_id * oid )
427430{
428431 struct object_info oi = OBJECT_INFO_INIT ;
429- struct odb_read_stream stream = {
430- .close = close_istream_incore ,
431- .read = read_istream_incore ,
432+ struct odb_incore_read_stream stream = {
433+ .base . close = close_istream_incore ,
434+ .base . read = read_istream_incore ,
432435 };
436+ struct odb_incore_read_stream * st ;
433437 int ret ;
434438
435- oi .typep = & stream .type ;
436- oi .sizep = & stream .size ;
437- oi .contentp = (void * * )& stream .u . incore . buf ;
439+ oi .typep = & stream .base . type ;
440+ oi .sizep = & stream .base . size ;
441+ oi .contentp = (void * * )& stream .buf ;
438442 ret = odb_read_object_info_extended (r -> objects , oid , & oi ,
439443 OBJECT_INFO_DIE_IF_CORRUPT );
440444 if (ret )
441445 return ret ;
442446
443- CALLOC_ARRAY (* out , 1 );
444- * * out = stream ;
447+ CALLOC_ARRAY (st , 1 );
448+ * st = stream ;
449+ * out = & st -> base ;
450+
445451 return 0 ;
446452}
447453
0 commit comments