S
Shea Martin
If I have a class Foo like this:
class Foo
{
public:
Foo()
{
mData = new char[ time() % 1000 ];
}
~Foo()
{
delete [] mData;
}
private:
char* mData;
};
Now if I create a Foo object using the 'placement' new like so:
void* raw = malloc( sizeof(Foo()) );
Foo *foo = new(raw) Foo();
foo.mData will not be taken from my memory pool, correct? There is no
way to know that how much memory Foo() will allocate. But it *would* be
nice to have the mData memory in the same pool as my foo object.
Any tips or tricks that I am overlooking, that would allow me to do this
(without access to the Foo class)?
Thanks,
~S
class Foo
{
public:
Foo()
{
mData = new char[ time() % 1000 ];
}
~Foo()
{
delete [] mData;
}
private:
char* mData;
};
Now if I create a Foo object using the 'placement' new like so:
void* raw = malloc( sizeof(Foo()) );
Foo *foo = new(raw) Foo();
foo.mData will not be taken from my memory pool, correct? There is no
way to know that how much memory Foo() will allocate. But it *would* be
nice to have the mData memory in the same pool as my foo object.
Any tips or tricks that I am overlooking, that would allow me to do this
(without access to the Foo class)?
Thanks,
~S