how to check that chHeapAlloc can do the job

Discussions and support about ChibiOS/RT, the free embedded RTOS.
Post Reply
vrollei
Posts: 163
Joined: Sun Nov 13, 2016 8:44 am
Been thanked: 26 times

how to check that chHeapAlloc can do the job

Post by vrollei »

Hi,

how can I check that RT is ready and it is possible to call chHeapAlloc?
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: how to check that chHeapAlloc can do the job

Post by Giovanni »

Hi,

After calling chSysInit() you can do anything, no need to check.

Giovanni
vrollei
Posts: 163
Joined: Sun Nov 13, 2016 8:44 am
Been thanked: 26 times

Re: how to check that chHeapAlloc can do the job

Post by vrollei »

Giovanni,

the problem is that there is no way to call it before:

std::vector<int> v1 = {1, 2};

so I need to check what to call in new operator: malloc or chHeapAlloc
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: how to check that chHeapAlloc can do the job

Post by Giovanni »

Calling malloc or chHeapAlloc in the same system does not look like a good idea, those share the same heap so problems are to be expected.

Consider that ChibiOS syscall.c uses the memory core allocator, so even using malloc before chSysInit is not going to work. You need to defer those allocations.

Giovanni
Post Reply