Re: Virtual networking (not the rathole thread :-)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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)


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]