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

Leverage std::make_unique & std::make_shared to create objects in the heap #3254

Merged
merged 1 commit into from
Oct 2, 2024

Conversation

eduar-hte
Copy link
Contributor

what

Replace naked new calls to create object instances in the heap that are then used to create std::unique_ptr & std::shared_ptr instances.

why

Simplifies code and follows C++ Core Guidelines, see R.22: Use make_shared() to make shared_ptrs & R.23: Use make_unique() to make unique_ptrs

Additionally, the use of std::make_shared allows for an optimization by which the shared pointer's control block and the object can be allocated in the same memory block, which increasees memory locality (and thus performance).

- Simpler code & more efficient because control block can be allocated
  with object.
Copy link

sonarcloud bot commented Sep 10, 2024

@marcstern marcstern added the 3.x Related to ModSecurity version 3.x label Sep 20, 2024
@airween airween merged commit 9a1155c into owasp-modsecurity:v3/master Oct 2, 2024
49 checks passed
@airween
Copy link
Member

airween commented Oct 2, 2024

@eduar-hte - thanks again for this PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.x Related to ModSecurity version 3.x
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants