Final update:
As I discovered, neither chHeapAlloc nor malloc (which behave in the same way) preserve polymorphism, because they are just raw memory allocators and they do not actually properly initialize the object.
I solved my problem by allocating memory using chHeapAlloc and subsequently using ...
Search found 8 matches
- Thu Jan 20, 2022 4:13 pm
- Forum: ChibiOS/RT
- Topic: chHeapAlloc with polymorphic classes
- Replies: 4
- Views: 5294
- Thu Jan 20, 2022 3:39 pm
- Forum: ChibiOS/RT
- Topic: chHeapAlloc with polymorphic classes
- Replies: 4
- Views: 5294
Re: chHeapAlloc with polymorphic classes
Also, yes, you were absolutely right. I tried substituting chHeapAlloc with malloc and the problem is the same .
- Thu Jan 20, 2022 3:25 pm
- Forum: ChibiOS/RT
- Topic: chHeapAlloc with polymorphic classes
- Replies: 4
- Views: 5294
Re: chHeapAlloc with polymorphic classes
Thank you Giovanni.
For anybody who feels like taking a closer look at the code, I think it's relevant to specify that the Base pointers that are being initialized are actually contained into a container class, as follows
class Base {
public:
Base *next = NULL;
Base *prev = NULL;
virtual ...
For anybody who feels like taking a closer look at the code, I think it's relevant to specify that the Base pointers that are being initialized are actually contained into a container class, as follows
class Base {
public:
Base *next = NULL;
Base *prev = NULL;
virtual ...
- Thu Jan 20, 2022 2:09 pm
- Forum: ChibiOS/RT
- Topic: chHeapAlloc with polymorphic classes
- Replies: 4
- Views: 5294
chHeapAlloc with polymorphic classes
Hello,
I am writing a program using the Arduino environment and the ChRt library https://github.com/greiman/ChRt , developing for the Teensy MicroMod.
As you may know, the Arduino environment allows for programming in C++, so this is the language that I'm using. I am implementing a dynamic ...
I am writing a program using the Arduino environment and the ChRt library https://github.com/greiman/ChRt , developing for the Teensy MicroMod.
As you may know, the Arduino environment allows for programming in C++, so this is the language that I'm using. I am implementing a dynamic ...
- Sun Nov 28, 2021 9:27 pm
- Forum: General Support
- Topic: chPoolAlloc fails system state check
- Replies: 1
- Views: 2734
chPoolAlloc fails system state check
Hello,
I am building an application in which I need to allocate and free objects, so I thought I'd do this with a memory pool. The problem is that if I call chPoolAlloc when the runtime system state checks are active, the system halts when I try to instantiate a new object from the pool. If the ...
I am building an application in which I need to allocate and free objects, so I thought I'd do this with a memory pool. The problem is that if I call chPoolAlloc when the runtime system state checks are active, the system halts when I try to instantiate a new object from the pool. If the ...
- Sun Nov 14, 2021 9:24 pm
- Forum: General Support
- Topic: Deliver the same message queue to many threads
- Replies: 4
- Views: 4446
Re: Deliver the same message queue to many threads
Follow-up question: what if the number of the threads interested in processing the messages wasn't static, but could change at run time?
- Sun Nov 14, 2021 9:20 pm
- Forum: General Support
- Topic: Deliver the same message queue to many threads
- Replies: 4
- Views: 4446
Re: Deliver the same message queue to many threads
Grazie Giovanni! Che celerità!
- Sun Nov 14, 2021 8:55 pm
- Forum: General Support
- Topic: Deliver the same message queue to many threads
- Replies: 4
- Views: 4446
Deliver the same message queue to many threads
Hello,
I am trying to program a device that will have MIDI as an input. The device will run multiple threads, some will be interested in the MIDI input, some won't. The threads that are interested in the MIDI messages will process the incoming information, each in a different way. What do you think ...
I am trying to program a device that will have MIDI as an input. The device will run multiple threads, some will be interested in the MIDI input, some won't. The threads that are interested in the MIDI messages will process the incoming information, each in a different way. What do you think ...