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.

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<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");
}
..
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Fullscreen
1
2
<prj.conf>
CONFIG_HEAP_MEM_POOL_SIZE=1024
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Fullscreen
1
2
3
4
<output>
here1
malloc is null
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX