MCPcopy Create free account
hub / github.com/Ray-D-Song/lexe / alloc_byte_ref

Function alloc_byte_ref

modules/llrt_buffer/src/buffer.rs:127–134  ·  view source on GitHub ↗
(ctx: &Ctx<'js>, byte_ref: &[u8], length: usize)

Source from the content-addressed store, hash-verified

125}
126
127fn alloc_byte_ref<'js>(ctx: &Ctx<'js>, byte_ref: &[u8], length: usize) -> Result<Value<'js>> {
128 let mut bytes = vec![0; length];
129 let byte_ref_length = byte_ref.len();
130 for i in 0..length {
131 bytes[i] = byte_ref[i % byte_ref_length];
132 }
133 Buffer(bytes).into_js(ctx)
134}
135
136fn alloc_unsafe(ctx: Ctx<'_>, size: usize) -> Result<Value<'_>> {
137 let mut bytes: Vec<MaybeUninit<u8>> = Vec::with_capacity(size);

Callers 1

allocFunction · 0.85

Calls 3

BufferClass · 0.70
lenMethod · 0.45
into_jsMethod · 0.45

Tested by

no test coverage detected