Re: Try/Catch

new topic     » goto parent     » topic index » view thread      » older message » newer message
jimcbrown said...
Spock said...

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

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu