Mettle

M0107Memory leak

Reported by the compiler as an error or warning.

mettle explain M0107

An allocation never escapes the function (not returned, not stored, not passed on) and is never freed: the memory is unreachable after the function returns.

Fix: free it on every path (a defer free(p); right after the allocation covers early returns), or hand ownership out.

Related