reallocarray()

The function changes the size of the memory block pointed to by ptr to be large enough for an array of nmemb elements, each of which is size bytes. It is equivalent to the call realloc(ptr, nmemb * size); reallocarray(ptr, nmemb, size)
ptr: pointer to already allocated memory arrea. nmemb: needed number of elements size: size of one elemet in bytes On success, the function returns a pointer to the newly allocated memory. On failure, it returns NULL and the original block of memory is left untouched.