[gst-devel] We should use alloca(3).

Andy Wingo wingo at pobox.com
Fri Apr 2 05:13:56 CEST 2004


Hey folks,

I think we should promote the use of alloca(3). (Yes, go read that man
page.)

Advantages:
 * It's damn fast. You can use it within processing functions without
   breaking realtime characteristics. Under GCC it inlines to a single 
   instruction.
 * When the element has a nonlocal exit, allocations are automagically  
   collected. Nonlocal exits (i.e., exits that don't allow cleanup) can 
   happen with cothreads. And also exceptions in languages like C++ and 
   Guile Scheme. (But not Python. And I couldn't figure it out for 
   Perl.)
 * It's easy. You have much less bookkeeping to do.

Disadvantages:
 * Some platforms don't support it. It's BSD, not POSIX.

To hack around the disadvantage, autoconf has AC_FUNC_ALLOCA. (Yes, go
read `info autoconf' if you're still with me.) It requires a bit of
build infrastructure support, possibly conditionally compiling an
alloca.o object file. Probably the best way to do this is to have a
gst-lib for alloca.

So, the infrastructure issues are nasty, but alloca is FAST FAST FAST,
and wonderfully easy and reliable. So I would be for adding it, but I
don't engage in masochism^H^H^Hbuild-system maintainance. Thoughts?
-- 
Andy Wingo <wingo at pobox.com>




More information about the gstreamer-devel mailing list