@@ -85,9 +85,7 @@ pygit2_odb_backend_read(void **ptr, size_t *sz,
85
85
if (!PyArg_ParseTuple (result , "ny#" , type , & bytes , sz ) || !bytes )
86
86
return GIT_EUSER ;
87
87
88
- /* XXX: This assumes the default libgit2 allocator is in use and will
89
- * probably segfault and/or destroy the universe otherwise */
90
- * ptr = malloc (* sz );
88
+ * ptr = git_odb_backend_data_alloc (_be , * sz );
91
89
if (!* ptr )
92
90
return GIT_EUSER ;
93
91
@@ -121,9 +119,7 @@ pygit2_odb_backend_read_prefix(git_oid *oid_out, void **ptr, size_t *sz,
121
119
& py_oid_out , type , & bytes , sz ) || !bytes )
122
120
return GIT_EUSER ;
123
121
124
- /* XXX: This assumes the default libgit2 allocator is in use and will
125
- * probably segfault and/or destroy the universe otherwise */
126
- * ptr = malloc (* sz );
122
+ * ptr = git_odb_backend_data_alloc (_be , * sz );
127
123
if (!* ptr )
128
124
return GIT_EUSER ;
129
125
@@ -486,9 +482,7 @@ OdbBackend_read(OdbBackend *self, PyObject *py_hex)
486
482
487
483
tuple = Py_BuildValue ("(ny#)" , type , data , sz );
488
484
489
- /* XXX: This assumes the default libgit2 allocator is in use and will
490
- * probably segfault and/or destroy the universe otherwise */
491
- free (data );
485
+ git_odb_backend_data_free (self -> odb_backend , data );
492
486
493
487
return tuple ;
494
488
}
@@ -527,9 +521,7 @@ OdbBackend_read_prefix(OdbBackend *self, PyObject *py_hex)
527
521
py_oid_out = git_oid_to_python (& oid_out );
528
522
tuple = Py_BuildValue ("(ny#O)" , type , data , sz , py_oid_out );
529
523
530
- /* XXX: This assumes the default libgit2 allocator is in use and will
531
- * probably segfault and/or destroy the universe otherwise */
532
- free (data );
524
+ git_odb_backend_data_free (self -> odb_backend , data );
533
525
534
526
return tuple ;
535
527
}
0 commit comments