when i try to malloc at kernel mod i get screamed by the compiler :
res=(ListNode*)malloc(sizeof(ListNode));
and the compiler is screaming :
/root/ex3/ex3mod.c:491: error: implicit declaration of function ‘malloc’
what should i do ?
when i try to malloc at kernel mod i get screamed by the compiler :
res=(ListNode*)malloc(sizeof(ListNode));
and the compiler is screaming :
/root/ex3/ex3mod.c:491: error: implicit declaration of function ‘malloc’
what should i do ?
You can't use libraries in the kernel. None whatsoever.
This means that ANY function you're calling in the kernel needs to be defined in the kernel. Linux does not define a malloc, hence you can't use it.
There is a memory allocator and a family of memory allocation functions. Read the kernel docs on the memory allocator for more information.
Incidentially, there are a few functions the kernel defines which are in the standard C library as well; this is for convenience.
It does, for instance, defined snprintf