Closed rpelliard closed 6 months ago
Thanks for the PR! I'm a little uncertain about using usize
for these values since they are defined as size_t
in libgit2. I think there is still some uncertainty if usize should always be the same as size_t (see https://github.com/rust-lang/rust/issues/88345). Perhaps to be on the safe side, they should be defined as size_t?
@ehuss Happy to do that change ! Just to make sure I understand correctly, do you suggest casting the usize
to libc::size_t
(or core::ffi::size_t
?) before passing it to libgit2, or completely changing the param/return types of the public interface to stop using usize
completely ?
Good question. I would probably just change the types of the function signatures to be libc::size_t
. Since it is a type alias, it probably won't matter much, and I believe will allow the caller to use usize values without any issues.
It is a bit unfortunate that the usize↔size_t relationship isn't clearer. Being a type alias (and not a newtype wrapper) makes it even more ambiguous.
Makes sense, I pushed an update to use libc::size_t
as parameter and return type
Thanks! One more thing, I'm pretty sure these need to be unsafe. There is no synchronization in modifying these values, so they should only be done on the main thread before any threads are spawned. (At least, that is my understanding. Interaction with C globals seems like a dark art.)
Good point, done !
@ehuss Thanks ! Would you be open to a release containing these changes ? I prepared https://github.com/rust-lang/git2-rs/pull/1036
This adds bindings for the mwindow options (https://libgit2.org/libgit2/#HEAD/group/libgit2/git_libgit2_opts)
This will avoid calling libgit2-sys directly to set these options, see related issues where this would be useful: