Search code examples
apimemorylinux-kernelallocation

A question about usage of kernel API method kstrtol()


int kstrtol (   const char * s,
    unsigned int base,
    long * res);

Can someone advise me on whether I need to allocate memory for long * res before invoking this kernel API method? I couldn't find a clear answer online.

TIA

Vinod


Solution

  • yes, the res should point a allocated memory, for example: long value; const char *buf; .... .... kstrtol(buf, 10, &value);