Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Expand array linux kernel module

Tags:

c

linux-kernel

i have an array

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

i need to expand this array each time i call this function Note: Realloc can't be used in linux kernel i dont know if it exists

like image 854
Mohamed Gamal Avatar asked Dec 16 '22 00:12

Mohamed Gamal


1 Answers

Roll your own realloc but be noted that realloc is a poorly designed function interface. Just allocate a new buffer with kmalloc and memcpy the old data into the new buffer; that's essentially all that realloc does if it cannot expand the buffer in place.

like image 85
Burton Samograd Avatar answered Jan 02 '23 14:01

Burton Samograd