summaryrefslogtreecommitdiffhomepage
path: root/examples/rust/upload-reflector/src/lib.rs
diff options
context:
space:
mode:
authorAndrew Clayton <a.clayton@nginx.com>2023-10-17 18:59:02 +0100
committerAndrew Clayton <a.clayton@nginx.com>2023-10-17 19:01:06 +0100
commit9b17f64d301334b999a8138037d32ff72e951018 (patch)
tree1f8cd4f0f6dede637b349270f0841c1c4da8b662 /examples/rust/upload-reflector/src/lib.rs
parent73d0914bc1d1f3a4b1b3e28815d892ef2143be0f (diff)
downloadunit-wasm-9b17f64d301334b999a8138037d32ff72e951018.tar.gz
unit-wasm-9b17f64d301334b999a8138037d32ff72e951018.tar.bz2
examples/rust: Do some simplification around unsafe {} blocks
We can put the unsafe keyword as part of the function definition, getting rid of the unsafe {} blocks in the functions themselves. Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
Diffstat (limited to '')
-rw-r--r--examples/rust/upload-reflector/src/lib.rs20
1 files changed, 8 insertions, 12 deletions
diff --git a/examples/rust/upload-reflector/src/lib.rs b/examples/rust/upload-reflector/src/lib.rs
index ac48b56..ccef351 100644
--- a/examples/rust/upload-reflector/src/lib.rs
+++ b/examples/rust/upload-reflector/src/lib.rs
@@ -18,22 +18,18 @@ static mut TOTAL_RESPONSE_SENT: usize = 0;
static mut REQUEST_BUF: *mut u8 = null_mut();
#[no_mangle]
-pub extern "C" fn uwr_response_end_handler() {
- unsafe {
- TOTAL_RESPONSE_SENT = 0;
- }
+pub unsafe extern "C" fn uwr_response_end_handler() {
+ TOTAL_RESPONSE_SENT = 0;
}
#[no_mangle]
-pub extern "C" fn uwr_request_end_handler() {
- unsafe {
- if REQUEST_BUF.is_null() {
- return;
- }
-
- uwr_free(REQUEST_BUF);
- REQUEST_BUF = null_mut();
+pub unsafe extern "C" fn uwr_request_end_handler() {
+ if REQUEST_BUF.is_null() {
+ return;
}
+
+ uwr_free(REQUEST_BUF);
+ REQUEST_BUF = null_mut();
}
pub fn upload_reflector(ctx: *mut luw_ctx_t) -> i32 {