Take the address of malloc,free,realloc,calloc,strdup#136
Conversation
|
Why do we need to move these functions to libcc2rs? |
To be able to write let mut pmalloc: Option<unsafe fn(u64) -> *mut ::libc::c_void> = Some(libcc2rs::malloc_unsafe); |
|
Ok, but why can't it write let mut pmalloc: Option<unsafe fn(u64) -> *mut ::libc::c_void> = Some(libc::malloc);? |
For rules that are translated using a single function call, for example For rules where we write a custom body, for example the previous fwrite: Also for refcount translation rules where we won't do |
Actually, no. I just tested doing this and it errors because the type of maloc is I will have to check if it's practical to solve this problem or it's better to keep malloc_unsafe as a libcc2rs function |
|
Uhm, ok, then it's an ABI problem. It's a bit annoying if we have to start adding wrappers for every single function in libc. but the alternative would be to have a more heavyweight function pointer that would know how to dispatch calls to different ABI variants. |
No description provided.