> >>> + if (id != NULL) {
> >>
> >>It's safe to call free(NULL), so , please, don't check.
> > [Rick] Does it mean that we override the original free() method, so that it
> > won't crash when we call free(NULL)? If so, that is good and I don't need
> > to check here.
>
> It's part of a C standard starting at least from C89:
> """
> 4.10.3.2 The free function
> ...
> If ptr is a null pointer, no action occurs.
> """
>
> 'man 3 free' suggests the same.
It's also part of the coding style document (more for Rick than for
Ilya):
Functions that destroy an instance of a dynamically-allocated type should
accept and ignore a null pointer argument. Code that calls such a function
(including the C standard library function ``free()``) should omit a
null-pointer check. We find that this usually makes code easier to read.
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev