Re: Try/Catch
- Posted by ghaberek (admin) Feb 17, 2015
- 4012 views
If an allocation originates outside the routine (eg, in my fast string allocator or my dib32 library or font library etc.. which are used a lot in my programs) there is now direct exposure to memory leaks should an exception occur when the prgram is using them.
So: Graphics, Fonts, Sound, ASM, Printing, other Windows ops have now been exposed to memory risks should an exception occur while they are being used.
Not so. Just make sure that your wrapper for the dib32/font library calls delete_routine() on each pointer that is returned by the library. Then, when an exception occurs, and the objects go out of scope, delete_routine() will clean them up for you.
This is also what finally is for: to cleanup the resource regardless of what happens in try or catch.
-Greg