Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions examples/test_hacktober.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include <stdlib.h>
Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you for reaching out to contribute.

This PR fixes a memory leak in the test.c example. Previously, an array allocated with malloc was not freed, causing 20 bytes of memory to remain allocated when the program exited.

I'm not sure I understand: which "test.c example" are you referring to? Could you supply the full path? And your PR seems to be adding a brand new directory examples/, rather than editing an existing file?

Copy link
Author

Choose a reason for hiding this comment

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

Thank you for your feedback and patience @derekbruening!

I apologize for the confusion in my PR description. You're absolutely right - this PR is not fixing an existing file. Instead, it's creating a new example file at examples/test_hacktober.c.

To clarify:

  • File created: examples/test_hacktober.c (new file)
  • Purpose: Provide a simple example demonstrating intentional memory leaks for Dr. Memory testing and education
  • Intent: This was meant as a Hacktoberfest contribution to add basic example files

I should have titled this PR "Add test_hacktober.c example" rather than "Fix memory leak" - that was misleading.

Regarding your questions in PR #2568 about the bigger picture:

  • I realize now I should have discussed creating an examples/ directory before submitting these PRs
  • I don't have a clear plan for how these would integrate with automated tests
  • I was trying to contribute during Hacktoberfest but didn't properly understand the project's needs

What I should do:

  1. Close these PRs (Fix memory leak in test example #2567, Add second memory leak #2568) as they weren't well thought out
  2. Study the project more thoroughly
  3. File a proper feature request if I want to propose an examples directory
  4. Wait for maintainer feedback before implementing

Would you prefer I close these PRs, or would you like me to revise them with proper context and planning?

#include <stdio.h>

int main() {
int *leak = malloc(sizeof(int) * 5); // intentional memory leak
int *arr = malloc(sizeof(int) * 10);
free(arr); // properly freed
printf("Hello Hacktoberfest!\n");
return 0;
}