MCPcopy Create free account
hub / github.com/awslabs/llrt / alloc_byte_ref

Function alloc_byte_ref

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

Source from the content-addressed store, hash-verified

136}
137
138fn alloc_byte_ref<'js>(ctx: &Ctx<'js>, byte_ref: &[u8], length: usize) -> Result<Value<'js>> {
139 let mut bytes = vec![0; length];
140 let byte_ref_length = byte_ref.len();
141 for i in 0..length {
142 bytes[i] = byte_ref[i % byte_ref_length];
143 }
144 Buffer(bytes).into_js(ctx)
145}
146
147fn alloc_unsafe(ctx: Ctx<'_>, size: usize) -> Result<Value<'_>> {
148 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