Skip to content

Commit

Permalink
Mark schedule_with_runloop/unschedule_from_runloop as unsafe
Browse files Browse the repository at this point in the history
  • Loading branch information
faern committed Jan 30, 2024
1 parent 7633a12 commit 8370ad2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ Line wrap the file at 100 chars. Th
## [Unreleased]
### Changed
- Bump minimum supported Rust version (MSRV) to 1.64.0.
- Breaking: Mark `SCNetworkReachability::schedule_with_runloop` and `unschedule_from_runloop` as
`unsafe`. They accept a raw pointer that it dereferences. Figuring out a safe API around this is
left as an exercise for the future.

### Fixed
- Fix memory leak in `SCNetworkReachability::set_callback`.
Expand Down
14 changes: 12 additions & 2 deletions system-configuration/src/network_reachability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,12 @@ impl SCNetworkReachability {
/// See [`SCNetworkReachabilityScheduleFromRunLoop`] for details.
///
/// [`SCNetworkReachabilityScheduleFromRunLoop`]: https://developer.apple.com/documentation/systemconfiguration/1514894-scnetworkreachabilityschedulewit?language=objc
pub fn schedule_with_runloop(
///
/// # Safety
///
/// The `run_loop_mode` must not be NULL and must be a pointer to a valid run loop mode.
/// Use `core_foundation::runloop::kCFRunLoopCommonModes` if you are unsure.
pub unsafe fn schedule_with_runloop(
&self,
run_loop: &CFRunLoop,
run_loop_mode: CFStringRef,
Expand All @@ -210,7 +215,12 @@ impl SCNetworkReachability {
/// See [`SCNetworkReachabilityUnscheduleFromRunLoop`] for details.
///
/// [`SCNetworkReachabilityUnscheduleFromRunLoop`]: https://developer.apple.com/documentation/systemconfiguration/1514899-scnetworkreachabilityunschedulef?language=objc
pub fn unschedule_from_runloop(
///
/// # Safety
///
/// The `run_loop_mode` must not be NULL and must be a pointer to a valid run loop mode.
/// Use `core_foundation::runloop::kCFRunLoopCommonModes` if you are unsure.
pub unsafe fn unschedule_from_runloop(
&self,
run_loop: &CFRunLoop,
run_loop_mode: CFStringRef,
Expand Down

0 comments on commit 8370ad2

Please sign in to comment.