I am brand new to rust but was proficient in C.
I want to generate wasm from rust but that is probably not
the problem here. I want to create on the fly a linearized relocatable tree data structure created of
chunks, themselves mostly constituted of inlined arrays. The catch: I know the size of arrays only at time creation of a chunk. I guess the rest I can figure out.
Once created the tree and its content are read only.
In the pseudo code below, I restrict myself to one array per chunk.
Next, I will need to traverse these trees from JavaScript.
But I guess I must go thru Implementing Life - Rust and WebAssembly
to be capable to post any sensible question on that second issue.
use std::alloc::{alloc, dealloc, Layout};
Struct {
U32 offset_sibling;
U32 offset parent;
U32 array1[sizearray1];
}
let layout = Layout::new::<u16>();
let tree root = alloc(layout);
fn create_son_node(u32 parent_offset, u32 sizearray1 ) { … }
fn create_sibling(u32 sibling_offset, u32 sizearray1) { … }
If the tree grows too big, I will use a realloc but the whole
structure is connex.
If someone can give me the code for create_son_node
I would be unstuck. or better even point me to the relevant docs. Thx.