mirror of
https://github.com/penpot/penpot.git
synced 2025-05-13 22:26:39 +02:00
🎉 Deserialize shape data in wasm
This commit is contained in:
parent
22b01c63b5
commit
0bfcc1f854
6 changed files with 140 additions and 18 deletions
|
@ -7,7 +7,7 @@ pub extern "C" fn alloc_bytes(len: usize) -> *mut u8 {
|
|||
panic!("Bytes already allocated");
|
||||
}
|
||||
|
||||
let mut buffer = Box::new(Vec::<u8>::with_capacity(len));
|
||||
let mut buffer = Box::new(vec![0u8; len]);
|
||||
let ptr = buffer.as_mut_ptr();
|
||||
|
||||
unsafe { BUFFERU8 = Some(buffer) };
|
||||
|
@ -23,3 +23,8 @@ pub fn buffer_ptr() -> *mut u8 {
|
|||
let buffer = unsafe { BUFFERU8.as_mut() }.expect("uninitializied buffer");
|
||||
buffer.as_mut_ptr()
|
||||
}
|
||||
|
||||
pub fn bytes() -> Vec<u8> {
|
||||
let buffer = unsafe { BUFFERU8.take() }.expect("uninitialized buffer");
|
||||
*buffer
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue