Lucciefr
Lua code caving, injection and exploration framework
Macros
macro.h File Reference

Go to the source code of this file.

Macros

#define UNUSED(x)   (void)(x)
 this macro is useful to get rid of compiler warnings
 
#define lengthof(array)   (sizeof(array) / sizeof(array[0]))
 macro to retrieve "length" (= number of elements) of an array
 
#define TRY   do
 start a TRY block. More...
 
#define FINALLY   while (0);
 close a TRY block
 
#define MAX(x, y)   ((x) > (y) ? (x) : (y))
 maximum of (x, y)
 
#define MIN(x, y)   ((x) < (y) ? (x) : (y))
 minimum of (x, y)
 
#define ABS(a)   ((a) < 0 ? -(a) : (a))
 absolute value of a
 

Macro Definition Documentation

#define TRY   do

start a TRY block.

TRY { ... } FINALLY is syntactic sugar for creating an explicit do { ... } while (0); block. The idea is that such a block can be left with a break statement in case of errors, to properly handle cleaning up etc.

stuff = malloc(some_size);
TRY {
    do_something_with_stuff();
    if (error) break;
    do_more_stuff();
} FINALLY
free(stuff);