Page 1 of 1
how to check that chHeapAlloc can do the job
Posted: Fri Dec 22, 2017 12:43 pm
by vrollei
Hi,
how can I check that RT is ready and it is possible to call chHeapAlloc?
Re: how to check that chHeapAlloc can do the job
Posted: Fri Dec 22, 2017 12:50 pm
by Giovanni
Hi,
After calling chSysInit() you can do anything, no need to check.
Giovanni
Re: how to check that chHeapAlloc can do the job
Posted: Fri Dec 22, 2017 1:02 pm
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
Re: how to check that chHeapAlloc can do the job
Posted: Fri Dec 22, 2017 3:29 pm
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