Skip to content

Commit

Permalink
Use raw_ptr methods in message.sw (FuelLabs#3139)
Browse files Browse the repository at this point in the history
Following up on this:
FuelLabs#2828 (comment)

> However, the changes you had to send_message seemed a bit buggy.
send_message is only tested in token_ops currently so no surprise that
Ci was passing. Regardless, I reverted the implementation of
send_message to how it was, for the most part. We can iterate on that in
the future.

@mohammadfawaz, it seems like `raw_ptr::read()` didn't behave like I
assumed it would. Still made use of `::add()` and `::write()` to pack
`alloc()`s together and get rid of one `__addr_of()`, but the other one
stayed.

Co-authored-by: Joshua Batty <[email protected]>
  • Loading branch information
AlicanC and JoshuaBatty authored Oct 26, 2022
1 parent 7bee2b2 commit f63973a
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions sway-lib-std/src/message.sw
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@ pub fn send_message(recipient: b256, msg_data: Vec<u64>, coins: u64) {
// data and recipient values there
if !msg_data.is_empty() {
size = msg_data.len() * 8;
let data_heap_buffer = alloc(size);
recipient_heap_buffer = alloc(32);
recipient_heap_buffer = alloc(32 + size);
recipient_heap_buffer.write(recipient);
let data_heap_buffer = recipient_heap_buffer.add(32);
msg_data.buf.ptr.copy_to(data_heap_buffer, size);
let addr_of_recipient = __addr_of(recipient);
addr_of_recipient.copy_to(recipient_heap_buffer, 32);
};

let mut index = 0;
Expand Down

0 comments on commit f63973a

Please sign in to comment.