@@ -168,23 +168,31 @@ impl ReentrantMutex {
168168 }
169169
170170 pub unsafe fn init ( & mut self ) {
171- c:: InitializeCriticalSection ( self . inner . get ( ) . as_mut_ptr ( ) ) ;
171+ c:: InitializeCriticalSection ( ( & mut * self . inner . get ( ) ) . as_mut_ptr ( ) ) ;
172172 }
173173
174174 pub unsafe fn lock ( & self ) {
175- c:: EnterCriticalSection ( self . inner . get ( ) . get_ref ( ) ) ;
175+ // `init` must have been called, so this is now initialized and
176+ // we can call `get_ref`.
177+ c:: EnterCriticalSection ( ( & mut * self . inner . get ( ) ) . get_ref ( ) ) ;
176178 }
177179
178180 #[ inline]
179181 pub unsafe fn try_lock ( & self ) -> bool {
180- c:: TryEnterCriticalSection ( self . inner . get ( ) . get_ref ( ) ) != 0
182+ // `init` must have been called, so this is now initialized and
183+ // we can call `get_ref`.
184+ c:: TryEnterCriticalSection ( ( & mut * self . inner . get ( ) ) . get_ref ( ) ) != 0
181185 }
182186
183187 pub unsafe fn unlock ( & self ) {
184- c:: LeaveCriticalSection ( self . inner . get ( ) . get_ref ( ) ) ;
188+ // `init` must have been called, so this is now initialized and
189+ // we can call `get_ref`.
190+ c:: LeaveCriticalSection ( ( & mut * self . inner . get ( ) ) . get_ref ( ) ) ;
185191 }
186192
187193 pub unsafe fn destroy ( & self ) {
188- c:: DeleteCriticalSection ( self . inner . get ( ) . get_ref ( ) ) ;
194+ // `init` must have been called, so this is now initialized and
195+ // we can call `get_ref`.
196+ c:: DeleteCriticalSection ( ( & mut * self . inner . get ( ) ) . get_ref ( ) ) ;
189197 }
190198}
0 commit comments