A
Alex Vinokur
The memory allocation issue in embedded systems is usually critical..
How can one manage that?
1. Via 'new'
char* p = new (nothrow) char [SOME_SIZE];
if (p == 0)
{
// He we know that it is impossible to allocate the requested memory
// We can do something relevant.
}
2. But how to manage memory allocation in containers for embedded
systems?
For instance,
vector<Foo> v;
Foo f;
v.push_back(f);
push_back() returns no values.
So, how can we know (except try-catch) that it is impossible to
allocate the requested memory in push_back()?
How can one manage that?
1. Via 'new'
char* p = new (nothrow) char [SOME_SIZE];
if (p == 0)
{
// He we know that it is impossible to allocate the requested memory
// We can do something relevant.
}
2. But how to manage memory allocation in containers for embedded
systems?
For instance,
vector<Foo> v;
Foo f;
v.push_back(f);
push_back() returns no values.
So, how can we know (except try-catch) that it is impossible to
allocate the requested memory in push_back()?