[vlc-devel] [PATCH 1/2] libvlc: Add Rust API for writing modules in rust

Rémi Denis-Courmont remi at remlab.net
Sun Sep 20 08:29:44 CEST 2020


Le sunnuntaina 20. syyskuuta 2020, 2.00.20 EEST Romain Vimont a écrit :
> To solve the problem, you propose to call libc::malloc() from Rust and
> free() from C (or malloc() from C and libc::free() from Rust). I like
> this solution, but IIUC, it is not guaranteed to be correct, because the
> allocators used by Rust and C may be different:
> > To free the data behind the C pointer you should call a C function
> > that does it, so that definitely the same C’s allocator is used. If
> > the pointer comes from C’s malloc, then Rust’s libc::free may work,
> > except it’s dangerous to do so if Windows DLLs are involved, since
> > each DLL may have separate runtime.

The VLC code base has been exchanging heap allocations and file descriptors 
between DLLs all the time. It's been working fine, and at this point, it is 
very deeply ingrained into the code base, so it has to work fine.

This problem only exists if you set up the build system in a stupid manner 
like LAVfilters does.

It might be a problem if you want to use LibVLC from a Rust application. But I 
believe that that's out of scope of this patchset.

-- 
雷米‧德尼-库尔蒙
http://www.remlab.net/





More information about the vlc-devel mailing list