 <p>That doesn't "guarantee" a result from <a href="http://linux.die.net/man/3/malloc" rel="nofollow"><code>malloc()</code></a>. If malloc returns <code>NULL</code> there's probably a reason for it (out of memory for example). And you might throw yourself into an infinite loop.</p> <p>Furthermore, if you're running this on a Linux platform:</p> <blockquote> <p>By default, Linux follows an optimistic memory allocation strategy. This means that when malloc() returns non-NULL there is no guarantee that the memory really is available.</p> </blockquote> <p>That means that lets say calling malloc over and over again did happen to return something non-NULL, due to Linux's "optimistic" strategy, a non-NULL still doesn't guarantee you got anything that will work.</p> <p>I think this code is setting you up for a debugging nightmare.</p>