@@ -168,23 +168,31 @@ impl ReentrantMutex {
168
168
}
169
169
170
170
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 ( ) ) ;
172
172
}
173
173
174
174
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 ( ) ) ;
176
178
}
177
179
178
180
#[ inline]
179
181
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
181
185
}
182
186
183
187
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 ( ) ) ;
185
191
}
186
192
187
193
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 ( ) ) ;
189
197
}
190
198
}
0 commit comments