On Mon, 2007-11-19 at 13:34 -0800, David King wrote:
> On-topic from <http://ubuntuforums.org/showthread.php?t=612606>:
> 
> I'm interested in audio, so I'm looking over the (frankly horrible)  
> documentation for this new "Pulse Audio" thing, and I see this  
> function in its shared lib:
> 
>      pa_xmalloc()
>      Allocates the specified number of bytes, just like malloc() does.
>      However, in case of OOM, terminate.

Complete insanity!!

Don't they think that malloc returns 0 for a reason? That Kernighan and
Ritchie were both plain stupid (the evidence suggests they weren't)?
That none of the ANSI & ISO people noticed?

> Sorry,

Don't apologise - the only sorry thing is this API call.

>  but anyone who puts a call to exit() in a shared library  
> should simply be shot dead. That's really, really crummy, amateurish  
> programming. In a shared lib, if something fails, the professional  
> thing to do is return some error code/signal to the app, indicating  
> that the function failed. Let the app decide what it wants to do. You  
> don't terminate the app on your own.

Absolutely. As someone who already uses pulseaudio (and has been lucky
enough not to have random app exits yet) I'd be happy if you pointed out
the error of their ways to them. Hopefully then they'll fix it before my
apps start exiting.

Shame really, because the concept is great (and many years overdue) and
it does seem to work quite well. Hmm, better go and increase swap size
though...

> God help us if this pulse audio thing is ever chosen to replace ALSA  
> in the kernel. This will make Linux stability and reliability go to  
> hell if you have operating system calls terminating apps at will.

Well you're quite safe there at least, pulse is a userland sound server
and not a sound driver at all, so it'll never go anywhere near kernel
space. (Besides there's quite a few kernel hackers that'd grind the
perpetrator's digits off before letting such code near the kernel.)

Cheers,

Martin.

Reply via email to