Eliminating inherited overlong MACRO

Posted by ExpatEgghead on Stack Overflow See other posts from Stack Overflow or by ExpatEgghead
Published on 2010-05-26T06:29:32Z Indexed on 2010/05/26 6:31 UTC
Read the original article Hit count: 136

Filed under:
|
|

I have inherited a very long set of macros from some C algorithm code.They basically call free on a number of structures as the function exits either abnormally or normally. I would like to replace these with something more debuggable and readable. A snippet is shown below

#define FREE_ALL_VECS {FREE_VEC_COND(kernel);FREE_VEC_COND(cirradCS); FREE_VEC_COND(pixAccum).....
#define FREE_ALL_2D_MATS  {FREE_2D_MAT_COND(circenCS); FREE_2D_MAT_COND(cirradCS_2); } 
#define FREE_ALL_IMAGES {immFreeImg(&imgC); immFreeImg(&smal.....
#define COND_FREE_ALLOC_VARS {FREE_ALL_VECS FREE_ALL_2D_MATS FREE_ALL_IMAGES}

What approach would be best? Should I just leave well alone if it works? This macro set is called twelve times in one function. I'm on Linux with gcc.

© Stack Overflow or respective owner

Related posts about c++

Related posts about c