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

fix: avoid memory leaks in event_map #1043

Merged
merged 1 commit into from
Dec 19, 2023

Conversation

rept1d
Copy link
Contributor

@rept1d rept1d commented Dec 19, 2023

This PR fixes memory leaks detected by Valgrind which occur because events allocated in initialization of eventmap are never deallocated.

These leaks are harmless because these objects are currently supposed to live for the whole duration of the program, but it's still good to not have these leaks at all. I fix them by making the pointers stored in eventmap (renamed to event_map for better readability) point to events with static storage duration. This way we also avoid unnecessary memory allocations.

I should note that it seems a bit weird to me that these event objects live that long in the first place. They have no reason for that other than making the implementation simpler. It might be worth looking for a cleaner a solution in a separate PR.

Code change checklist

  • I have ensured that all methods and functions are fully documented using doxygen style comments.
  • My code follows the coding style guide.
  • I tested that my change works before raising the PR.
  • I have ensured that I did not break any existing API calls.
  • I have not built my pull request using AI, a static analysis tool or similar without any human oversight.

Copy link

netlify bot commented Dec 19, 2023

Deploy Preview for dpp-dev ready!

Name Link
🔨 Latest commit 536a49f
🔍 Latest deploy log https://app.netlify.com/sites/dpp-dev/deploys/658150ab8f0c1d0008420d2e
😎 Deploy Preview https://deploy-preview-1043--dpp-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@CLAassistant
Copy link

CLAassistant commented Dec 19, 2023

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions bot added the code Improvements or additions to code. label Dec 19, 2023
@Jaskowicz1
Copy link
Contributor

Congrats on your first PR! I know you said you've tested this, but have you ran a unit test with this and made sure there's no errors there?

@braindigitalis
Copy link
Contributor

pretty sure there's already a type called event_map (a container of guild events) but apart from that looks good

@rept1d
Copy link
Contributor Author

rept1d commented Dec 19, 2023

pretty sure there's already a type called event_map (a container of guild events) but apart from that looks good

I don't think there is, there are only scheduled_event_map and event_member_map.

@braindigitalis braindigitalis merged commit 912f8b3 into brainboxdotcc:dev Dec 19, 2023
43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code Improvements or additions to code.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants