Re:Show HN: Boot Windows 10 Directly into Linux Desktop of C...
by richardwhiuk on Thursday March 02, 2017 @04:05AM
(#13772709)
You can't have a single cleanup (because subsequent calls use memory/handles from prior - otherwise you'd have a function wrapper), so it ends up getting really nasty - at which point, the logic feels clearer (and easier to match alloc and free) if you have indented blocks. The change I'd make to the code would be to have a shorter indent block.
[ Parent
| on HN ]
Re:Show HN: Boot Windows 10 Directly into Linux Desktop of C...
by int_19h on Thursday March 02, 2017 @08:19PM
(#13779993)
> You can't have a single cleanup (because subsequent calls use memory/handles from prior
Why not? You just initialize them all to NULL (or INVALID_HANDLE_VALUE etc, as appropriate). And then in your cleanup block, you check whether each was initialized, and clean it up. So long as you consistently do this in reverse order of their initialization, it works.