summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--API-Rust.md16
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 {