There are several helper slab allocator APIs, friends of the k[m|z]alloc() API family. These include the kcalloc() and kmalloc_array() APIs for allocating memory for an array, as well as krealloc(), whose behavior is analogous to realloc(3), the familiar user space API.
In conjunction with allocating memory for an array of elements, the array_size() and struct_size() kernel helper routines can be very helpful. In particular, struct_size() has been heavily used to prevent (and indeed fix) many integer overflow (and related) bugs when allocating an array of structures, a common task indeed. As a quick example, here's a small code snippet from net/bluetooth/mgmt.c:
rp = kmalloc(struct_size(rp, addr, i), GFP_KERNEL);
if (!rp) {
err = -ENOMEM; [...]
It's worth browsing through the include/linux/overflow.h kernel header file.
kzfree() is like kfree() but zeroes out ...