int fun(int a) { /* may raise NoEnoughMemoryException */ vector buf(SIZE); if (condition1) { while (loop1) { ... } return 1; } ... return 0; /* no need for kfree, buf gets deleted automatically on both return statements *and* in case exception is raised */ }