|
|
|
|
|
by jonhohle
125 days ago
|
|
It’s pedantic, but in the malloc example, I’d put the defer immediately after the assignment. This makes it very obvious that the defer/free goes along with the allocation. It would run regardless of if malloc succeeded or failed, but calling free on a NULL pointer is safe (defined to no-op in the C-spec). |
|
free may accept a NULL pointer, but it also doesn't need to be called with one either.