@@ -18,6 +18,7 @@ VALUE rb_cRuggedBlob;
1818VALUE rb_cRuggedBlobSig ;
1919
2020extern const rb_data_type_t rugged_object_type ;
21+ extern const rb_data_type_t rugged_repository_type ;
2122
2223/*
2324 * call-seq:
@@ -143,7 +144,7 @@ static VALUE rb_git_blob_from_buffer(VALUE self, VALUE rb_repo, VALUE rb_buffer)
143144 Check_Type (rb_buffer , T_STRING );
144145 rugged_check_repo (rb_repo );
145146
146- Data_Get_Struct (rb_repo , git_repository , repo );
147+ TypedData_Get_Struct (rb_repo , git_repository , & rugged_repository_type , repo );
147148
148149 error = git_blob_create_frombuffer (& oid , repo , RSTRING_PTR (rb_buffer ), RSTRING_LEN (rb_buffer ));
149150 rugged_exception_check (error );
@@ -170,7 +171,7 @@ static VALUE rb_git_blob_from_workdir(VALUE self, VALUE rb_repo, VALUE rb_path)
170171 FilePathValue (rb_path );
171172 rugged_check_repo (rb_repo );
172173
173- Data_Get_Struct (rb_repo , git_repository , repo );
174+ TypedData_Get_Struct (rb_repo , git_repository , & rugged_repository_type , repo );
174175
175176 error = git_blob_create_fromworkdir (& oid , repo , StringValueCStr (rb_path ));
176177 rugged_exception_check (error );
@@ -198,7 +199,7 @@ static VALUE rb_git_blob_from_disk(VALUE self, VALUE rb_repo, VALUE rb_path)
198199 FilePathValue (rb_path );
199200 rugged_check_repo (rb_repo );
200201
201- Data_Get_Struct (rb_repo , git_repository , repo );
202+ TypedData_Get_Struct (rb_repo , git_repository , & rugged_repository_type , repo );
202203
203204 error = git_blob_create_fromdisk (& oid , repo , StringValueCStr (rb_path ));
204205 rugged_exception_check (error );
@@ -253,7 +254,7 @@ static VALUE rb_git_blob_from_io(int argc, VALUE *argv, VALUE klass)
253254 rb_scan_args (argc , argv , "21" , & rb_repo , & rb_io , & rb_hint_path );
254255
255256 rugged_check_repo (rb_repo );
256- Data_Get_Struct (rb_repo , git_repository , repo );
257+ TypedData_Get_Struct (rb_repo , git_repository , & rugged_repository_type , repo );
257258
258259 if (!NIL_P (rb_hint_path )) {
259260 FilePathValue (rb_hint_path );
@@ -507,7 +508,7 @@ static VALUE rb_git_blob_to_buffer(int argc, VALUE *argv, VALUE self)
507508 rb_scan_args (argc , argv , "21" , & rb_repo , & rb_sha1 , & rb_max_bytes );
508509
509510 rugged_check_repo (rb_repo );
510- Data_Get_Struct (rb_repo , git_repository , repo );
511+ TypedData_Get_Struct (rb_repo , git_repository , & rugged_repository_type , repo );
511512
512513 blob = (git_blob * )rugged_object_get (repo , rb_sha1 , GIT_OBJ_BLOB );
513514
@@ -607,7 +608,7 @@ static VALUE rb_git_blob_merge_files(int argc, VALUE *argv, VALUE klass)
607608
608609 if (!NIL_P (rb_repo )) {
609610 rugged_check_repo (rb_repo );
610- Data_Get_Struct (rb_repo , git_repository , repo );
611+ TypedData_Get_Struct (rb_repo , git_repository , & rugged_repository_type , repo );
611612 }
612613
613614 if (!NIL_P (rb_options ))
@@ -638,6 +639,20 @@ static VALUE rb_git_blob_merge_files(int argc, VALUE *argv, VALUE klass)
638639 return rb_result ;
639640}
640641
642+ static void rb_git_hashsig__free (void * data )
643+ {
644+ git_hashsig * sig = (git_hashsig * ) data ;
645+ git_hashsig_free (sig );
646+ }
647+
648+ const rb_data_type_t rugged_hashsig_type = {
649+ .wrap_struct_name = "Rugged::Blob::HashSignature" ,
650+ .function = {
651+ .dfree = rb_git_hashsig__free ,
652+ },
653+ .flags = RUBY_TYPED_FREE_IMMEDIATELY ,
654+ };
655+
641656static VALUE rb_git_blob_sig_new (int argc , VALUE * argv , VALUE klass )
642657{
643658 int error , opts = 0 ;
@@ -664,7 +679,7 @@ static VALUE rb_git_blob_sig_new(int argc, VALUE *argv, VALUE klass)
664679
665680 rugged_exception_check (error );
666681
667- return Data_Wrap_Struct (klass , NULL , & git_hashsig_free , sig );
682+ return TypedData_Wrap_Struct (klass , & rugged_hashsig_type , sig );
668683}
669684
670685static VALUE rb_git_blob_sig_compare (VALUE self , VALUE rb_sig_a , VALUE rb_sig_b )
@@ -678,8 +693,8 @@ static VALUE rb_git_blob_sig_compare(VALUE self, VALUE rb_sig_a, VALUE rb_sig_b)
678693 rb_raise (rb_eTypeError , "Expected Rugged::Blob::HashSignature" );
679694 }
680695
681- Data_Get_Struct (rb_sig_a , git_hashsig , sig_a );
682- Data_Get_Struct (rb_sig_b , git_hashsig , sig_b );
696+ TypedData_Get_Struct (rb_sig_a , git_hashsig , & rugged_hashsig_type , sig_a );
697+ TypedData_Get_Struct (rb_sig_b , git_hashsig , & rugged_hashsig_type , sig_b );
683698
684699 result = git_hashsig_compare (sig_a , sig_b );
685700
0 commit comments