Implemented lz_da_remove and a memory analysis tool

This commit is contained in:
cannoli-fruit 2026-07-24 21:59:11 -04:00
commit 5a41640054
3 changed files with 131 additions and 0 deletions

34
examples/leak.c Normal file
View file

@ -0,0 +1,34 @@
#include <stdio.h>
#define LZ_MEM_ANALYZER
#define LAZY_IMPL
#include "../lazy.h"
typedef struct {
int payload;
void *next;
} LLNode;
int main () {
LLNode *root = malloc(sizeof(LLNode));
LLNode *curr = root;
int prevX = 0;
for (int i = 0; i < 10; ++i) {
LLNode *new = malloc(sizeof(LLNode));
curr->next = new;
new->payload = ++prevX;
curr = new;
}
curr = root;
while (curr->next) {
void *next = curr->next;
printf("%d\n", curr->payload);
free(curr);
curr = next;
}
free(curr);
lz_mem_debug();
return 0;
}