@@ -151,13 +151,11 @@ impl Request {
151
151
///
152
152
/// # Safety
153
153
/// Caller must ensure that type `T` matches the configuration type for the specified module.
154
- pub fn get_module_main_conf < T > ( & self , module : & ngx_module_t ) -> Option < & ' static T > {
154
+ pub unsafe fn get_module_main_conf < T > ( & self , module : & ngx_module_t ) -> Option < & ' static T > {
155
155
// SAFETY: main conf is either NULL or allocated with ngx_p(c)alloc and
156
156
// explicitly initialized by the module
157
- unsafe {
158
- let scf = * self . 0 . main_conf . add ( module. ctx_index ) ;
159
- scf. cast :: < T > ( ) . as_ref ( )
160
- }
157
+ let scf = * self . 0 . main_conf . add ( module. ctx_index ) ;
158
+ scf. cast :: < T > ( ) . as_ref ( )
161
159
}
162
160
163
161
/// Server-specific configuration for a module.
@@ -166,13 +164,11 @@ impl Request {
166
164
///
167
165
/// # Safety
168
166
/// Caller must ensure that type `T` matches the configuration type for the specified module.
169
- pub fn get_module_srv_conf < T > ( & self , module : & ngx_module_t ) -> Option < & ' static T > {
167
+ pub unsafe fn get_module_srv_conf < T > ( & self , module : & ngx_module_t ) -> Option < & ' static T > {
170
168
// SAFETY: server conf is either NULL or allocated with ngx_p(c)alloc and
171
169
// explicitly initialized by the module
172
- unsafe {
173
- let scf = * self . 0 . srv_conf . add ( module. ctx_index ) ;
174
- scf. cast :: < T > ( ) . as_ref ( )
175
- }
170
+ let scf = * self . 0 . srv_conf . add ( module. ctx_index ) ;
171
+ scf. cast :: < T > ( ) . as_ref ( )
176
172
}
177
173
178
174
/// Location-specific configuration for a module.
@@ -181,26 +177,26 @@ impl Request {
181
177
///
182
178
/// # Safety
183
179
/// Caller must ensure that type `T` matches the configuration type for the specified module.
184
- pub fn get_module_loc_conf < T > ( & self , module : & ngx_module_t ) -> Option < & ' static T > {
180
+ pub unsafe fn get_module_loc_conf < T > ( & self , module : & ngx_module_t ) -> Option < & ' static T > {
185
181
// SAFETY: location conf is either NULL or allocated with ngx_p(c)alloc and
186
182
// explicitly initialized by the module
187
- unsafe {
188
- let lcf = * self . 0 . loc_conf . add ( module. ctx_index ) ;
189
- lcf. cast :: < T > ( ) . as_ref ( )
190
- }
183
+ let lcf = * self . 0 . loc_conf . add ( module. ctx_index ) ;
184
+ lcf. cast :: < T > ( ) . as_ref ( )
191
185
}
192
186
193
187
/// Get Module context pointer
194
- fn get_module_ctx_ptr ( & self , module : & ngx_module_t ) -> * mut c_void {
195
- unsafe { * self . 0 . ctx . add ( module. ctx_index ) }
188
+ unsafe fn get_module_ctx_ptr ( & self , module : & ngx_module_t ) -> * mut c_void {
189
+ * self . 0 . ctx . add ( module. ctx_index )
196
190
}
197
191
198
192
/// Get Module context
199
- pub fn get_module_ctx < T > ( & self , module : & ngx_module_t ) -> Option < & T > {
200
- let ctx = self . get_module_ctx_ptr ( module) . cast :: < T > ( ) ;
193
+ ///
194
+ /// # Safety
195
+ /// Caller must ensure that type `T` matches the context type for the specified module.
196
+ pub unsafe fn get_module_ctx < T > ( & self , module : & ngx_module_t ) -> Option < & T > {
201
197
// SAFETY: ctx is either NULL or allocated with ngx_p(c)alloc and
202
198
// explicitly initialized by the module
203
- unsafe { ctx . as_ref ( ) }
199
+ self . get_module_ctx_ptr ( module ) . cast :: < T > ( ) . as_ref ( )
204
200
}
205
201
206
202
/// Sets the value as the module's context.
0 commit comments