This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to use malloc in nRF9160?

I can' initialize malloc. Any help?

I implement code like bellow.

<main.c>
..
char *Cmd_crlf;
..

void main(void)
{
    ..
    printk("here1\r\n");
    Cmd_crlf = (char *) malloc(10);
	if (Cmd_crlf == NULL) {
		printk("malloc is null\r\n");
	}
	..
}

<prj.conf>
CONFIG_HEAP_MEM_POOL_SIZE=1024

<output>

here1
malloc is null

Related