[Libvir] Virtual networking (not the rathole thread :-)

Richard W.M. Jones rjones at redhat.com
Mon Jan 29 09:19:29 UTC 2007


Karel Zak wrote:
>> +    return strdup(tapfdstr);
>          ^^^^^^^^^^^^^^^^^^^
>   where is allocation check?

There's a strong argument that you shouldn't check for out of memory 
errors on small heap allocations.  After all, in a typical C program 
there's a ratio somewhere around 10 : 1 of stack objects allocated : 
objects allocated on the heap (malloc, strdup).  Yet stack object 
allocation is almost never checked for failures.  So you're making your 
code considerably longer and harder to understand in order to catch 
failures in only 1 in 10 memory allocations.

Moreover on most Linux distributions the stack is limited to something 
uselessly small like 8 MB, which makes recursive algorithms fail when 
there's plenty of free memory around.

Rich.

-- 
Emerging Technologies, Red Hat  http://et.redhat.com/~rjones/
64 Baker Street, London, W1U 7DF     Mobile: +44 7866 314 421
  "[Negative numbers] darken the very whole doctrines of the equations
  and make dark of the things which are in their nature excessively
  obvious and simple" (Francis Maseres FRS, mathematician, 1759)




More information about the libvir-list mailing list