This a short snippet of code, with two calls to exit(3) in case of failure.
Do these calls deallocate memory allocated by malloc? Google search once says it does, a
When you exit the program, all allocated memory is reclaimed by the OS (both the stack and the heap). Your program doesn't leave any footprint in the RAM, unless you work outside the program's memory through buffer overflows and such.