Skip to content
Open
Show file tree
Hide file tree
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
14 changes: 14 additions & 0 deletions examples/leak_example2.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#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.

As in #2567, I am a little confused: so you are proposing creating a new directory examples/? Will these be used in automated tests? What is the bigger picture here: could you file a feature issue in the tracker and describe the goal and link this PR to that new issue?

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 @derekbruening for your patience and feedback.

I've just responded to your similar question in #2567, and the same applies here:

This PR is creating new example files (examples/leak_example2.c and examples/test_hacktober.c), not editing existing files. I should have made this clearer in my PR descriptions.

Regarding your questions about the bigger picture:

You're absolutely right to ask. I realize now that I:

  • Created these PRs during Hacktoberfest without proper discussion
  • Don't have a clear plan for how these integrate with the project
  • Should have filed a feature issue first before implementing

What I propose:

  1. I can close these PRs (Fix memory leak in test example #2567, Add second memory leak #2568, Add signal_buffer_leak example for memory leak detection #2569) since they were submitted without proper planning
  2. If the project would benefit from example files, I'm happy to file a proper feature request describing:
    • The purpose and use cases
    • How they'd integrate with documentation/tests
    • What examples would be most valuable
  3. Wait for maintainer feedback before implementing anything

I apologize for the confusion and for not following proper contribution procedures. Would you prefer I close these PRs?

#include <stdio.h>

/* leak_example2.c
* Intentional small memory leak for Dr. Memory demos
*/

int main(void) {
int *p = malloc(5 * sizeof(int)); // intentionally not freed
if (!p) return 1;
p[0] = 42; // use the memory so it's not optimized away
printf("Leak example 2\n");
return 0;
}
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>
#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;
}