xmalloc: Add and use xcalloc

Add a wrapper for calloc which checks for integer overflows in the
calculation of the size to allocate.

Use xcalloc to allocate an array of objects instead of calculating the
size ourselves, which might cause an integer overflow.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Merge remote-tracking branch 'upstream/master'