Replace malloc by xmalloc from utils.h (exit if alloc fails)