Changed uses of malloc + memset to calloc, now checking return values of calloc/malloc/mmap
Missed the return val of two calls to malloc
freed pointers are now set to NULL