On 5/2/11 7:24 AM, Rafal Somla wrote:
> Hi again,
> On 29/04/2011 21:56, Davi Arnaut wrote:
>> On 4/29/11 4:45 PM, Rafal Somla wrote:
>>> + if (m_buf)
>>> + free(m_buf);
>> free() handles NULL pointers just fine.
> Correct, but above code has 2 slight advantages:
> 1. It might be more efficient than calling free() in case m_buf is NULL.
It really doesn't make much of a difference. A good compiler is better
at making these kind of decisions -- on what is more efficient.
> 2. It will always work, even if on some exotic platform/configuration,
> free() does not handle NULL pointers.
This exotic platform/configuration won't be ANSI C. But, let's suppose
this exists: yes, your code will work, but will be the only piece
"working", because every other free in the server is going to crash upon
seeing a NULL pointer.