if xmalloc is used instead of malloc, then xfree should be used instead of free