Skip to content

Commit

Permalink
fix: Fix libc::write argument type.
Browse files Browse the repository at this point in the history
The argument type for libc::write is platform dependent. The
fix converts to the platform specific type using `TryInto`. This
fixes Windows builds.

Fixes #101.
  • Loading branch information
jetuk committed Sep 3, 2024
1 parent c84f966 commit 557a883
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion pyo3-polars/src/alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ impl PolarsAllocator {
if r.is_none() {
// Do not use eprintln; it may alloc.
let msg = b"failed to get allocator capsule\n";
unsafe { libc::write(2, msg.as_ptr() as *const libc::c_void, msg.len()) };
// Message length type is platform-dependent.
let msg_len = msg.len().try_into().unwrap();
unsafe { libc::write(2, msg.as_ptr() as *const libc::c_void, msg_len) };
}
r.unwrap_or(&FALLBACK_ALLOCATOR_CAPSULE)
})
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[toolchain]
channel = "nightly-2024-07-26"
channel = "stable"

0 comments on commit 557a883

Please sign in to comment.