I was trying to store the messages received by stream server into an arrayList of const u8.
However, I think I am doing something wrong.
Appending a slice made from “buf” delimited by “bytes_written” results on populating the arraylist with the same memory.
So instead, I used the allocator from the arrayLis to allocate a new slice and then copy the relevant bytes from the buffer.
It works but I am not confident with my solution, is there a better way to achieve the same thing?
Was it necessary to allocate the new slice prior to appending into the arraylist?
Thank you.
Here is the snippet I was talking about for reference
It is funny how much I struggled to make this a reply instead of an isolated comment haha.
That feels more ergonomic.
I was reading the source for dupe, and I saw that it is using @memcpy, do you how does it differ from std.mem.copyForwards? I do not know where to find the source code for the builtins…