Why not inserting a call to free automatically instead of forcing you to do it manually?
2. You can build abstractions that call free for you. The common withX callback-style function can be better typed with linear types and call free for you, for instance.
with-some-resource { res ->
// use res as you like
}
The with-some-resource function takes care of the resource management, while the type system takes care res doesn't escape the lambda.The original situation (malloc gives you a linear variable) handles what you want. A function that takes the variable but does not return it effectively "takes ownership of it" and the type system will force a free.
There's a "Linear Constraints" paper draft out there that emulates ownership and borrowing with linear types, and uses the titular new language feature to greatly improve ergonomics.