Skip to content

Commit 3f9dc0b

Browse files
committed
change: Direct usages of libc::{size_t, c_int} and std::ffi::c_void
1 parent bcf78e5 commit 3f9dc0b

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

src/odb_backend.rs

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
use crate::util::Binding;
55
use crate::{raw, Error, ErrorClass, ErrorCode, ObjectType, Oid};
66
use bitflags::bitflags;
7-
use libc::{c_int, size_t};
8-
use std::ffi::c_void;
97
use std::marker::PhantomData;
108
use std::mem::ManuallyDrop;
119
use std::ptr::NonNull;
@@ -241,7 +239,7 @@ bitflags! {
241239
/// [`git_odb_backend_data_free`]: raw::git_odb_backend_data_free
242240
pub struct OdbBackendAllocation {
243241
backend_ptr: *mut raw::git_odb_backend,
244-
raw: NonNull<c_void>,
242+
raw: NonNull<libc::c_void>,
245243
size: usize,
246244
}
247245
impl OdbBackendAllocation {
@@ -279,7 +277,7 @@ impl OdbBackendContext {
279277
/// `Some(allocation)` if the allocation succeeded.
280278
/// `None` otherwise. This usually indicates that there is not enough memory.
281279
pub fn alloc(&self, size: usize) -> Option<OdbBackendAllocation> {
282-
let data = unsafe { raw::git_odb_backend_data_alloc(self.backend_ptr, size as size_t) };
280+
let data = unsafe { raw::git_odb_backend_data_alloc(self.backend_ptr, size as libc::size_t) };
283281
let data = NonNull::new(data)?;
284282
Some(OdbBackendAllocation {
285283
backend_ptr: self.backend_ptr,
@@ -394,12 +392,12 @@ pub(crate) struct Backend<B> {
394392
}
395393
impl<B: OdbBackend> Backend<B> {
396394
extern "C" fn read(
397-
data_ptr: *mut *mut c_void,
398-
size_ptr: *mut size_t,
395+
data_ptr: *mut *mut libc::c_void,
396+
size_ptr: *mut libc::size_t,
399397
otype_ptr: *mut raw::git_object_t,
400398
backend_ptr: *mut raw::git_odb_backend,
401399
oid_ptr: *const raw::git_oid,
402-
) -> c_int {
400+
) -> libc::c_int {
403401
let backend = unsafe { backend_ptr.cast::<Self>().as_mut().unwrap() };
404402
let data = unsafe { data_ptr.as_mut().unwrap() };
405403
let size = unsafe { size_ptr.as_mut().unwrap() };
@@ -428,13 +426,13 @@ impl<B: OdbBackend> Backend<B> {
428426
}
429427
extern "C" fn read_prefix(
430428
oid_ptr: *mut raw::git_oid,
431-
data_ptr: *mut *mut c_void,
432-
size_ptr: *mut size_t,
429+
data_ptr: *mut *mut libc::c_void,
430+
size_ptr: *mut libc::size_t,
433431
otype_ptr: *mut raw::git_object_t,
434432
backend_ptr: *mut raw::git_odb_backend,
435433
oid_prefix_ptr: *const raw::git_oid,
436-
oid_prefix_len: size_t,
437-
) -> c_int {
434+
oid_prefix_len: libc::size_t,
435+
) -> libc::c_int {
438436
let backend = unsafe { backend_ptr.cast::<Self>().as_mut().unwrap() };
439437
let data = unsafe { data_ptr.as_mut().unwrap() };
440438
let size = unsafe { size_ptr.as_mut().unwrap() };
@@ -470,11 +468,11 @@ impl<B: OdbBackend> Backend<B> {
470468
raw::GIT_OK
471469
}
472470
extern "C" fn read_header(
473-
size_ptr: *mut size_t,
471+
size_ptr: *mut libc::size_t,
474472
otype_ptr: *mut raw::git_object_t,
475473
backend_ptr: *mut raw::git_odb_backend,
476474
oid_ptr: *const raw::git_oid,
477-
) -> c_int {
475+
) -> libc::c_int {
478476
let size = unsafe { size_ptr.as_mut().unwrap() };
479477
let otype = unsafe { otype_ptr.as_mut().unwrap() };
480478
let backend = unsafe { backend_ptr.cast::<Backend<B>>().as_mut().unwrap() };
@@ -497,7 +495,7 @@ impl<B: OdbBackend> Backend<B> {
497495
extern "C" fn exists(
498496
backend_ptr: *mut raw::git_odb_backend,
499497
oid_ptr: *const raw::git_oid,
500-
) -> c_int {
498+
) -> libc::c_int {
501499
let backend = unsafe { backend_ptr.cast::<Backend<B>>().as_mut().unwrap() };
502500
let oid = unsafe { Oid::from_raw(oid_ptr) };
503501
let context = OdbBackendContext { backend_ptr };
@@ -511,13 +509,13 @@ impl<B: OdbBackend> Backend<B> {
511509
0
512510
}
513511
}
514-
512+
515513
extern "C" fn exists_prefix(
516514
oid_ptr: *mut raw::git_oid,
517515
backend_ptr: *mut raw::git_odb_backend,
518516
oid_prefix_ptr: *const raw::git_oid,
519-
oid_prefix_len: size_t
520-
) -> c_int {
517+
oid_prefix_len: libc::size_t
518+
) -> libc::c_int {
521519
let backend = unsafe { backend_ptr.cast::<Self>().as_mut().unwrap() };
522520
let oid_prefix = unsafe { Oid::from_raw(oid_prefix_ptr) };
523521
let oid = unsafe { oid_ptr.cast::<Oid>().as_mut().unwrap() };

0 commit comments

Comments
 (0)