Skip to content

[#297]fix:event params() not being freed in events.c#306

Open
Labreo wants to merge 4 commits intoPecanProject:masterfrom
Labreo:297-fix-eventParams-not-freed
Open

[#297]fix:event params() not being freed in events.c#306
Labreo wants to merge 4 commits intoPecanProject:masterfrom
Labreo:297-fix-eventParams-not-freed

Conversation

@Labreo
Copy link
Copy Markdown
Contributor

@Labreo Labreo commented Mar 29, 2026

Summary

  • What: Fixed a memory leak in events.c by freeing eventParams before freeing the main EventNode.
  • Motivation: When events are created, memory is allocated for both the event node and its specific parameters. The old cleanup function (freeEventList) only freed the outer node, leaving the parameters in memory. This fix cleans up both, preventing memory leaks during simulations.

How was this change tested?

make smoke
python tools/smoke_check.py run verbose <list tests/smoke subdirectories with changed outputs>
make test

Reproduction steps

Not required.

Related issues

Checklist

  • Related issues are listed above. PRs without an approved, related issue may not get reviewed.
  • PR title has the issue number in it ("[#] <concise description of proposed change>")
  • Tests added/updated for new features (if applicable)
  • Documentation updated (if applicable)
  • docs/CHANGELOG.md updated with noteworthy changes
  • Code formatted with clang-format (run git clang-format if needed)

Note: See CONTRIBUTING.md for additional guidance. This repository uses automated formatting checks; if the pre-commit hook blocks your commit, run git clang-format to format staged changes.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a memory leak in SIPNET’s agronomic events cleanup by ensuring each EventNode’s type-specific eventParams allocation is freed when tearing down the global event linked list.

Changes:

  • Update freeEventList() to free(prev->eventParams) (when non-NULL) before freeing the EventNode.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug:Memory leak in freeEventList(): eventParams not freed

2 participants