[Ffmpeg-devel] Proposal: remove av_mallocz_static and friends

Rich Felker dalias
Wed Oct 11 21:49:36 CEST 2006

In the past we've had issues with people wanting to use libavcodec as
a dynamically loaded module encountering trouble with the static table
allocations, e.g. if multiple modules using libavcodec are loaded,
it's unclear who is responsible for freeing this data and either
memory leaks or corruption could result. I have a simple proposal for
getting rid of this nasty global state issue: remove av_*alloc*_static
API and just declare the space as arrays in the C source. As long as
they're uninitialized they'll be put in the BSS segment and the pages
won't use any memory until something actually writes to them. Of
course they also use no space on disk.

This seems much more elegant than the current system which has all
sorts of issues with dynamic loading/unloading and also with thread
safety. IMO with my proposal it's possible to make all the table
initializations thread-safe without any locking, and without the
possibility of leaking memory.


More information about the ffmpeg-devel mailing list