Use xrealloc(NULL, n, m) instead of xmalloc(n * m) to get overflow
check.
Add xreallocarray and remove nmemb argument from xrealloc.