Add leak_detector_c

This commit is contained in:
2025-04-24 10:01:18 +08:00
parent 1c28d55681
commit 6a4fb872f7
13 changed files with 337 additions and 9 deletions

20
leak_detector_c/test.c Normal file
View File

@@ -0,0 +1,20 @@
#include <malloc.h>
#include <stdlib.h>
#include "leak_detector_c.h"
int main()
{
atexit(report_mem_leak);
char *ptr1 = (char *)malloc(1);
int *ptr2 = (int *)calloc(1, sizeof(int));
float * ptr3 = (float *) calloc(15, sizeof(float));
free(ptr2);
dump_mem_leak();
return 0;
}