How it works...
Using the atexit function, register a function called freeup, ensuring that the freeup function will be invoked if the program terminates normally. The value returned by the atexit function is checked to see that it is zero only. If the value returned by the atexit function is a nonzero value, then that means the function is not registered successfully and the program will terminate after displaying an error message.
If the function is registered successfully, 20 bytes are dynamically allocated and the allocated memory block is assigned to a character pointer, str. If the str pointer is NULL, then this means an error has occurred in the allocation of the memory block. If it is confirmed that the str pointer is not NULL and ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access