Introduce xmalloc, helper to avoid wrong memory
allocation. It should also cleanup should malloc
fail.