by drostie · 13y ago · 0 comments
__attribute__((cleanup(free_indirect))) char *foo = strdup ("bar");
where free_indirect is a simple wrapper around free. It's used in the systemd code (making it GCC/LLVM-specific of course). allocate_memory();
scope(failure) free_memory();
setup_interrupts();
scope(failure) teardown_interrupts();
setup_registers();
The scope keyword is for saying that if you get to this point, then do such and such at end of scope. scope(failure)/scope(success)/scope(exit), for exitting scope by exception/return/either. Is kind of nice.In general, though, I think it's more about presentation than the language per se. I've often felt that an IDE or editor that could selectively highlight or hide the different pathways through the code would be a very useful tool.