Hacker News new | ask | show | jobs
by _dain_ 35 days ago
As you add more code between the "open" and the "close", you introduce more opportunities for control flow to accidentally skip the "close" (leak), or call it more than once (double-free). It forces you to use single-return style, which can make some things very awkward to express.

You're basically doing "defer"-style cleanup manually; you may as well just use the real "defer" if your compiler supports it. It's supposed to be official in a future standard, too.