Extend Linux kernel module

I have an array

char* temp;
temp=kmalloc(3,GFP_KERNEL);

I need to expand this array every time I call this function Note. Realloc cannot be used in the linux kernel. I don't know if he exists

+3
source share
4 answers

Download your own realloc, but note that realloc is a poorly designed functional interface. Just allocate the new buffer with kmalloc and memcpy old data into the new buffer; which is essentially all that realloc does if it cannot expand the buffer in place.

+6
source

<linux/slab.h>has krealloc()to go with kmalloc(). This was added in 2007 / kernel 2.6.22.

+2
source

, mmapped ( - ), , .

+1

All Articles