Click to See Complete Forum and Search --> : Abort in recursive algorithem


ranzf
April 1st, 2002, 03:31 AM
Hi,
does anyone can think about how to implement abort
in recursive algorithem (e.g. parser)
the problem is that some memory allocations may possiblly occur before we have to abort.
i thought of a way to register all the allocations in a singleton object and in case of abort to deallocate them using that object. ?

Russell Robinson
April 2nd, 2002, 12:05 AM
There are two good ways to do this.

1. If you're using a language with exception handling, use an exception.
2. If not, then your function(s) must return a code that says "there's been an error". It's then simply a matter of returning back up the recursion chain when you see an error return.


Russell Robinson (russellr@rootsoftware.com)
Author of TTMaker (Advanced Timetabling Software)
http://www.rootsoftware.com

Manish Malik
April 9th, 2002, 09:22 PM
Which language are you using? If it is that critical, use a language with automatic garbage collection maybe.....C# ??


Manish
http://www.manishmalik.com

Discuss it all at the Developer Forum : http://www.codeguru.com/cgi-bin/bbs/wt/wwwthreads.pl?action=list&Board=devforum ...