Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework operator new and delete overloads to allocate memory directly #71

Closed
SamVanheer opened this issue Nov 20, 2021 · 0 comments
Closed
Assignees
Labels
enhancement New feature or request

Comments

@SamVanheer
Copy link
Collaborator

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.

@SamVanheer SamVanheer added the enhancement New feature or request label Nov 20, 2021
@SamVanheer SamVanheer self-assigned this Nov 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant