The overloaded operator new and delete used in CBaseEntity have a second parameter used to pass the entvars_t instance to allow the engine to allocate memory for the entity. This is legal C++, but the syntax can cause problems. Clang-tidy complains about it and says destructors won't be called as a result.
Allocate the memory directly instead. This eliminates a call into the engine and allows dynamic memory allocation in the client as well without having to implement the engine function. This also ensures both overloads follow exactly the standard without requiring conditional compilation.
Note that the engine allocates the memory using calloc, so this will not reduce engine heap memory usage.
The overloaded operator new and delete used in
CBaseEntity
have a second parameter used to pass theentvars_t
instance to allow the engine to allocate memory for the entity. This is legal C++, but the syntax can cause problems. Clang-tidy complains about it and says destructors won't be called as a result.Allocate the memory directly instead. This eliminates a call into the engine and allows dynamic memory allocation in the client as well without having to implement the engine function. This also ensures both overloads follow exactly the standard without requiring conditional compilation.
Note that the engine allocates the memory using
calloc
, so this will not reduce engine heap memory usage.