clean exit - suggestions?

From: lallous (lallous_at_lgwm.org)
Date: 01/09/04


Date: Fri, 9 Jan 2004 14:19:42 +0200

Hello,

I have a function like:

void fnc() {
char *mem1, *mem2, *mem3, *mem4;
// lots of code...
// mem1, 2, 3, 4 got allocated
// lots of code and condition checks
if (condition_failed)
{
  // blah blah
  // free mem1, mem2, mem3, mem4
  return;
}

if (condition2_failed)
{
  // blah blah
  // free mem1, mem2, ...
 return;
}

// here the end of routine (clean exit code):
// free mem1, mem2, mem3, mem4
}

Usually, I would use compiler specific solution by putting most of the code
in __try() and the clean exit code in _finally() block then to reach the
clean exit code I would invoke __leave.

Or use lables and then goto clean_exit

Any better way, other than goto or compiler specific solution?

--
Elias


Relevant Pages

  • clean exit - suggestion - C version
    ... I would use compiler specific solution by putting most of the code ... in __tryand the clean exit code in _finallyblock then to reach the ... other than goto or compiler specific solution? ...
    (comp.lang.c)
  • Re: C++ to VB conversion and preprocessor definition
    ... The #define preprocessor definition tells the compiler to effectively ... perform a search and replace on the sourcecode as it is compiling, replacing ...
    (microsoft.public.dotnet.languages.vb)
  • Re: FreeRTOS / SafeRTOS in a Medical Device
    ... delete "in blah blah blah" ... Which is why it is difficult to do validation for a GCC compiler compared to a compiler from say Byte craft where they have all the documentation from day 1 and control the process. ... if I was to take that landing gear and integrate it ... onto another plane then I would need the entire lifecycle and design data so ...
    (comp.arch.embedded)
  • Re: MODULEand USE versus Argument Passing
    ... I am quite aware of special array type cases, which show some compiler ... for three interfaces (Module, Subroutine contained in module, and external ... -| COMMON blah blah I,J, blah blah ...
    (comp.lang.fortran)
  • Re: my first class - getting an error
    ... I'm not sure what the problem you're having interpreting the error is, but I _suspect_ you are being led astray by the "...and no extension method blah blah blah" part. ... In some cases, in a well-intentioned effort to provide you with additional guidance, the compiler introduces some concept that you may not even be aware of, completely confusing the issue. ... But the "Calculus" method exists in the "summing" class, ...
    (microsoft.public.dotnet.languages.csharp)