@@ -66,25 +66,19 @@ impl NativeEventStream {
6666 }
6767 }
6868
69- fn build_context ( & mut self ) -> * const fsevent_sys:: FSEventStreamContext {
70- eprintln ! ( "ctx sending: {:?}" , self . sender_heap) ;
71- & fs:: FSEventStreamContext {
72- version : 0 ,
73- info : self . sender_heap as * mut _ ,
74- retain : None ,
75- release : Some ( release_context) ,
76- copy_description : None
77- }
78- }
79-
8069 pub fn start ( & mut self ) {
8170 unsafe {
82- let x = self . build_context ( ) ;
8371 eprintln ! ( "Creating stream: {}" , self . since_when) ;
8472 let stream = fs:: FSEventStreamCreate (
8573 kCFAllocatorDefault,
8674 callback,
87- x,
75+ & fs:: FSEventStreamContext {
76+ version : 0 ,
77+ info : self . sender_heap as * mut _ ,
78+ retain : None ,
79+ release : Some ( release_context) ,
80+ copy_description : None
81+ } ,
8882 self . path . as_concrete_TypeRef ( ) ,
8983 self . since_when ,
9084 0.15 ,
@@ -128,17 +122,8 @@ impl NativeEventStream {
128122}
129123
130124extern "C" fn release_context ( info : * mut c_void ) {
131- // Safety:
132- // - The [documentation] for `FSEventStreamContext` states that `release` is only
133- // called when the stream is deallocated, so it is safe to convert `info` back into a
134- // box and drop it.
135- //
136- // [docs]: https://developer.apple.com/documentation/coreservices/fseventstreamcontext?language=objc
137- unsafe {
138- drop ( Box :: from_raw (
139- info as * mut CallbackContext ,
140- ) ) ;
141- }
125+ let ctx_ptr = info as * mut CallbackContext ;
126+ unsafe { drop ( Box :: from_raw ( ctx_ptr) ) ; }
142127}
143128
144129extern "C" fn callback (
0 commit comments