NAME
EGC - (MACRO) Goto to "cleanup" label if argument is ERROR
SYNOPSIS
#include "l/l_error.h"
Example compile flags (system dependent):
-DLINUX_X86_64 -DLINUX_X86_64_OPTERON -DGNU_COMPILER
-I/home/kobus/include
-L/home/kobus/misc/load/linux_x86_64_opteron -L/usr/lib/x86_64-linux-gnu
-lKJB -lfftw3 -lgsl -lgslcblas -ljpeg -lSVM -lstdc++ -lpthread -lSLATEC -lg2c -lacml -lacml_mv -lblas -lg2c -lncursesw
int EGC(int);
DESCRIPTION
This macro jumps to a label names "cleanup" if its argument is ERROR. It is
convenient when ERE would cause memory leaks by not freeing memory allocated
earlier in the function. Below is a usage example.
| int my_func()
{
Error err = NO_ERROR;
Matrix* m = NULL
Matrix* m2 = NULL
ERE(get_target_matrix(&m, 5, 5));
EGC(err = get_target_matrix(&m2, 3, 3));
...
cleanup:
free_matrix(m);
free_matrix(m2);
return err;
}
Notice that the first call uses ERE, since there's nothing to free. The
second call needs to use EGC, since m needs to be freed before
returning. Also notice that you need to set err inside EGC, so the error
is returned at the end of the function.
Further, if the debug level is greater than 0, then a message is added to the
list of messages using add_errror(); That line is:
(EGC on line [line] of [file].
DISCLAIMER
This software is not adequatedly tested. It is recomended that
results are checked independantly where appropriate.
AUTHOR
Kobus Barnard
DOCUMENTER
Kobus Barnard
SEE ALSO
NOTE_ERROR
,
ERE
,
ERN
,
ER
,
EPE
,
ETE
,
EPETE
,
EPETE
,
ESBRE
,
BATCH_EPETE
,
NRE
,
NGC
,
NRN
,
NR
,
NPE
,
NTE
,
NPETE
,
NPETE