Fix three memory leaks
Use dlmalloc instead of malloc