diff options
author | Andrew Clayton <a.clayton@nginx.com> | 2024-07-02 03:06:32 +0100 |
---|---|---|
committer | Andrew Clayton <a.clayton@nginx.com> | 2024-07-02 03:06:32 +0100 |
commit | 4d4f1f2284d54dfabf58246034b8fc7fd0282f83 (patch) | |
tree | 74c5474460ca3d1a18e934719270227f23bed349 | |
parent | 2cf492f49cfb05c5083c99a38634c2f40b6d3e84 (diff) | |
download | unit-wasm-4d4f1f2284d54dfabf58246034b8fc7fd0282f83.tar.gz unit-wasm-4d4f1f2284d54dfabf58246034b8fc7fd0282f83.tar.bz2 |
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
-rw-r--r-- | API-Rust.md | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/API-Rust.md b/API-Rust.md index 66e65d5..bef2e7d 100644 --- a/API-Rust.md +++ b/API-Rust.md @@ -492,7 +492,7 @@ static mut REQUEST_BUF: *mut u8 = null_mut(); */ ... */ #[no_mangle] pub extern "C" fn uwr_request_handler(addr: *mut u8) -> i32 { - let ctx: *mut luw_ctx_t = unsafe { &mut CTX }; + let ctx: *mut luw_ctx_t = unsafe { addr_of_mut!(CTX) }; if unsafe { REQUEST_BUF.is_null() } { uwr_init_ctx(ctx, addr, 0 /* Response offset */); @@ -507,7 +507,7 @@ pub extern "C" fn uwr_request_handler(addr: *mut u8) -> i32 { */ uwr_set_req_buf( ctx, - unsafe { &mut REQUEST_BUF }, + unsafe { addr_of_mut!(REQUEST_BUF) }, LUW_SRB_APPEND | LUW_SRB_ALLOC | LUW_SRB_FULL_SIZE, ); } else { @@ -811,7 +811,7 @@ Example ```Rust #[no_mangle] pub extern "C" fn uwr_request_handler(addr: *mut u8) -> i32 { - let ctx: *mut luw_ctx_t = unsafe { &mut CTX }; + let ctx: *mut luw_ctx_t = unsafe { addr_of_mut!(CTX) }; if unsafe { REQUEST_BUF.is_null() } { uwr_init_ctx(ctx, addr, 0 /* Response offset */); @@ -826,7 +826,7 @@ pub extern "C" fn uwr_request_handler(addr: *mut u8) -> i32 { */ uwr_set_req_buf( ctx, - unsafe { &mut REQUEST_BUF }, + unsafe { addr_of_mut!(REQUEST_BUF) }, LUW_SRB_APPEND | LUW_SRB_ALLOC | LUW_SRB_FULL_SIZE, ); } else { @@ -868,14 +868,18 @@ Example ```Rust pub extern "C" fn uwr_request_handler(addr: *mut u8) -> i32 { - let ctx: *mut luw_ctx_t = unsafe { &mut CTX }; + let ctx: *mut luw_ctx_t = unsafe { addr_of_mut!(CTX) }; let mut f; let bytes_wrote: isize; let mut total = unsafe { TOTAL_BYTES_WROTE }; if total == 0 { uwr_init_ctx(ctx, addr, 0); - uwr_set_req_buf(ctx, unsafe { &mut REQUEST_BUF }, LUW_SRB_NONE); + uwr_set_req_buf( + ctx, + unsafe { addr_of_mut!(REQUEST_BUF) }, + LUW_SRB_NONE + ); f = File::create("/var/tmp/large-file.dat").unwrap(); } else { |