[ros-dev] Error handling

Phillip Susi psusi at cfl.rr.com
Mon Apr 11 18:11:41 CEST 2005


That doesn't really work.  You don't want to do XXX and then clean it up 
right away, you want to allocate XXX, then allocate YYY, then allocate 
ZZZ, then do something with them, then clean up and return ( or maybe 
not clean up on success ), but if there is an error allocating any of 
the 3, then you need to clean up the ones that succeeded already.

Jakob Eriksson wrote:
  > Indeed. This was my immediate thought too. Maybe something like
> this, or maybe not, but you get the idea.
> 
> 
> DoNtXXX()
> {
>    NSTATUS Status;
> 
>    Status = NtXXX();
> 
>    cleanupXXX();
> 
>    return !NT_SUCCESS(Status);
> }
> 
> 
> DoNtZZZ()
> {
>    NSTATUS Status;
> 
>    Status = NtZZZ();
> 
>    cleanupZZZ();
> 
>    return !NT_SUCCESS(Status);
> }
> 
> DoNtYYY()
> {
>    NSTATUS Status;
> 
>    Status = NtYYY();
> 
>    cleanupYYY();
> 
>    return !NT_SUCCESS(Status);
> }
> 
> 
> NTSTATUS DoSomething()
> {
>    return DoNtXXX() || DoNtYYY() || DoNtZZZ();
> }
> 
> 
> 
> _______________________________________________
> Ros-dev mailing list
> Ros-dev at reactos.com
> http://reactos.com:8080/mailman/listinfo/ros-dev
> 



More information about the Ros-dev mailing list