You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by "xyjixyjixyji (via GitHub)" <gi...@apache.org> on 2025/02/24 13:37:27 UTC

Re: [I] new feature: provides a way to control memory allocation and deallocation [opendal]

xyjixyjixyji commented on issue #5365:
URL: https://github.com/apache/opendal/issues/5365#issuecomment-2678441892

   I think at this point there is only one solution if we want to use a **custom allocator**.
   
   We expose an API like this
   
   ```Rust
   type AllocFn = unsafe extern "C" fn(size: usize) -> *mut u8;
   type DeallocFn = unsafe extern "C" fn(ptr: *mut u8, size: usize);
   
   #[no_mangle]
   pub extern "C" fn opendal_set_global_allocator(alloc: AllocFn, dealloc: DeallocFn);
   ```
   
   And users call `opendal_set_global_allocator()` before any dynamic memory allocation, we can also force this so that this can only be called once.
   
   If everyone agree on this I could do this in a few days. \cc @Xuanwo @tbEgg 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org