V
Vinu
Hi,
I am maintaining a C++ project which is a server which continuously
receives requeste from clients.
I have noticed that we overload the new operator and in it then call
malloc to allocate memory.
Specifically the code is something like this.
template <class T>
class CSimpleList
{
public:
CSimpleList()
{
// some code
}
inline void* operator new(size_t tSize){ return malloc(tSize); }
inline void operator delete( void* p ){ free(p); }
};
Is it all right to use it like this. Because i was under the impression
that even after you overload the new operator, it does memory
allocation implicitly(i.e even if you dont do a malloc or some other
kind of memory allocation).
So in the above case, wont memory be allocated twice.
Thanks
Vinu
I am maintaining a C++ project which is a server which continuously
receives requeste from clients.
I have noticed that we overload the new operator and in it then call
malloc to allocate memory.
Specifically the code is something like this.
template <class T>
class CSimpleList
{
public:
CSimpleList()
{
// some code
}
inline void* operator new(size_t tSize){ return malloc(tSize); }
inline void operator delete( void* p ){ free(p); }
};
Is it all right to use it like this. Because i was under the impression
that even after you overload the new operator, it does memory
allocation implicitly(i.e even if you dont do a malloc or some other
kind of memory allocation).
So in the above case, wont memory be allocated twice.
Thanks
Vinu