Ì used to make sure a pointer was not null before freeing it, so I would normally destroy dynamically created structs like this:
Node *destroy_node(Node *node) {
if (node) {
free(node);
}
return NULL;
}
But CERT MEM34 suggests that since free() accepts null pointers, I could as well write
Node *destroy_node(Node *node) {
free(node);
return NULL;
}
Is that correct?