The kernel code base is full of functions which allocate memory and Kmalloc (), then zero it with memset (). Recently, Pekka Enberg concluded so much of the this code could is cleaned up by using kcalloc () instead. Kcalloc () has this prototype:
void *kcalloc (size_t n, size_t size, unsigned int __nocast gfp_flags);
This function would allocate an array of n items, and would zero the entire array before returning it to the caller. Pekka ' s patch converted a number of Kmalloc ()/memset () pairs over to Kcalloc (), but this patch drew a complaint from Andre W Morton:
Notice how every conversion for you did passes in ' 1 ' in the ' the ' And that's going to happen again and again and again. Each callsite needlessly passing that silly third argument, adding text.
Very few callers actually need to allocate a array of items, so extra argument be unneeded in most. Each instance of this argument adds a bit to the size of the kernel, and, over time, which is adds up. The solution is to create yet another allocation function:
void *kzalloc (size_t size, unsigned int __nocast gfp_flags);
This function is returns a single, zeroed item. It has been added to-mm, with its appearance in the mainline to likely for happen.
Kzalloc zeroes the memory before Returninga pointer
Kcalloc allocates memory for an array, itis not a replacement for Kcalloc:
void *kcalloc (size_t n, size_t size, gfp_tflags)
Vmalloc is the same as Kmalloc, except itallocates memory this is only virtually contiguous. The underling physicalmemory can be discontiguous.
So Kmalloc can eventually being replaced by Acall to Kzalloc, but it are unlikely to solve your