pointers-memory · intermediate · ~15 min
Quantify the leak rather than just detecting it.
Implement int leak_count(const char *ops) returning how many allocations remain unfreed at the end of the trace ('a' allocates, 'f' frees a live allocation; an 'f' with nothing live is ignored).
int leak_count(const char *ops) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.