Simulates "malloc" and "free" commands in C