Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

Doxygen Source Code Documentation


Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search  

Amalloc.h

Go to the documentation of this file.
00001 #ifndef _AFNI_AMALLOC_HEADER_
00002 #define _AFNI_AMALLOC_HEADER_
00003 /************************************************************************
00004    Casting macros to fixup AFNI stuff for compiling with g++. 
00005    Original dealt with only malloc() casting stuff, but more
00006    has been added since.
00007 ************************************************************************/
00008 
00009 /*---------------------------------------------------------------------*/
00010 /*! Replacement for malloc(). */
00011 
00012 #define AFMALL(typ,siz)    (typ*) calloc(1,siz)
00013 
00014 /*---------------------------------------------------------------------*/
00015 /*! Replacement for realloc(). */
00016 
00017 #define AFREALL(v,typ,siz) (typ*) realloc((void*)v,sizeof(typ)*(siz))
00018 
00019 /*---------------------------------------------------------------------*/
00020 /*! Replacement for free(). */
00021 
00022 #define AFFREE(v)          free((void*)v)
00023 
00024 /*---------------------------------------------------------------------*/
00025 /*! Cast a function pointer to the right
00026     prototype and call it, for 0D transformations. */
00027 
00028 #define AFNI_CALL_0D_function(func,nar,far)                     \
00029  do{ void (*fp)(int,float *) = (void (*)(int,float *))(func) ;  \
00030      if( fp != NULL )                                           \
00031       fp( (nar) , (far) ) ;                                     \
00032  } while(0)
00033 
00034 /*---------------------------------------------------------------------*/
00035 /*! Cast a function pointer to the right
00036     prototype and call it, for 1D transformations. */
00037 
00038 #define AFNI_CALL_1D_function(func,nar,d1,d2,far)               \
00039  do{ void (*fp)(int,double,double,float *) =                    \
00040       (void (*)(int,double,double,float *))(func) ;             \
00041      if( fp != NULL )                                           \
00042       fp(nar,(double)d1,(double)d2,far) ;                       \
00043  } while(0)
00044 
00045 /*---------------------------------------------------------------------*/
00046 /*! Cast a function pointer to the right
00047     prototype and call it, for 1D transformations
00048     that also return a pointer to a string.      */
00049 
00050 #define AFNI_CALL_1D_funcstr(func,nar,d1,d2,far,str)            \
00051  do{ void (*fp)(int,double,double,float *,char **) =            \
00052       (void (*)(int,double,double,float *,char**))(func) ;      \
00053      if( fp != NULL )                                           \
00054       fp(nar,(double)d1,(double)d2,far,(char **)&(str)) ;       \
00055  } while(0)
00056 
00057 /*---------------------------------------------------------------------*/
00058 /*! Cast a function pointer to the right prototype
00059     and call it, for 1D transformations of images. */
00060 
00061 #define AFNI_CALL_1D_funcmrim(func,mage)                        \
00062  do{ void (*fp)(MRI_IMAGE *) = (void (*)(MRI_IMAGE *))(func) ;  \
00063      if( fp != NULL )                                           \
00064       fp(mage) ;                                                \
00065  } while(0)
00066 
00067 /*---------------------------------------------------------------------*/
00068 /*! Cast a function pointer to the right prototype
00069     and call it, for 1D transformations of images
00070     that also return a pointer to a string.       */
00071 
00072 #define AFNI_CALL_1D_funcmrimstr(func,mage,str)                 \
00073  do{ void (*fp)(MRI_IMAGE *,char **) =                          \
00074       (void (*)(MRI_IMAGE *,char **))(func) ;                   \
00075      if( fp != NULL )                                           \
00076       fp(mage,(char **)&(str)) ;                                \
00077  } while(0)
00078 
00079 /*---------------------------------------------------------------------*/
00080 /*! Cast a function pointer to the right
00081     prototype and call it, for 2D transformations. */
00082 
00083 #define AFNI_CALL_2D_function(func,n1,n2,d1,d2,far)             \
00084  do{ void (*fp)(int,int,double,double,float *) =                \
00085       (void (*)(int,int,double,double,float *))(func) ;         \
00086      if( fp != NULL )                                           \
00087       fp( (n1),(n2),(double)(d1),(double)(d2),far ) ;           \
00088  } while(0)
00089 
00090 /*---------------------------------------------------------------------*/
00091 /*! Cast a function pointer to the right
00092     prototype and call it, for projections.
00093     The output value is assigned to "val". */
00094 
00095 #define AFNI_CALL_proj_function(func,n,far,val)                 \
00096  do{ float (*fp)(int,float *) = (float (*)(int,float *))(func); \
00097      if( fp != NULL ) (val) = fp(n,far) ;                       \
00098  } while(0)
00099 
00100 /*---------------------------------------------------------------------*/
00101 /*! Cast a function pointer to the right
00102     prototype and call it, for FIM functions. */
00103 
00104 #define AFNI_CALL_fim_function(func,n,ts,ud,nb,vv)             \
00105  do{ void (*fp)(int,float *,void *,int,void *) =               \
00106       (void (*)(int,float *,void *,int,void *))(func) ;        \
00107      if( fp != NULL )                                          \
00108        fp(n,ts,(void *)(ud),nb,(void *)(vv)) ;                 \
00109  } while(0)
00110 
00111 /************************************************************************
00112      Macros to call functions with arguments of general types
00113      specified in the macro call, with various numbers of arguments.
00114      Functions returninothing (_VOID_) or return a value (_VALU_).
00115 ************************************************************************/
00116 
00117 /*---------------------------------------------------------------------*/
00118 #define AFNI_CALL_VOID_1ARG(func,typ1,arg1)                   \
00119  do{ void (*fp)(typ1) = (void (*)(typ1))(func) ;              \
00120      if( fp != NULL )                                         \
00121       fp((typ1)(arg1)) ;                                      \
00122  } while(0)
00123 
00124 /*---------------------------------------------------------------------*/
00125 #define AFNI_CALL_VALU_1ARG(func,vtyp,vval,typ1,arg1)         \
00126  do{ vtyp (*fp)(typ1) = (vtyp (*)(typ1))(func) ;              \
00127      if( fp != NULL )                                         \
00128       (vval) = fp((typ1)(arg1)) ;                             \
00129  } while(0)
00130 
00131 /*---------------------------------------------------------------------*/
00132 #define AFNI_CALL_VOID_2ARG(func,typ1,arg1,typ2,arg2)        \
00133  do{ void (*fp)(typ1,typ2) = (void (*)(typ1,typ2))(func) ;   \
00134      if( fp != NULL )                                        \
00135       fp((typ1)(arg1),(typ2)(arg2)) ;                        \
00136  } while(0)
00137 
00138 /*---------------------------------------------------------------------*/
00139 #define AFNI_CALL_VALU_2ARG(func,vtyp,vval,typ1,arg1,typ2,arg2) \
00140  do{ vtyp (*fp)(typ1,typ2) = (vtyp (*)(typ1,typ2))(func) ;      \
00141      if( fp != NULL )                                           \
00142       (vval) = fp((typ1)(arg1),(typ2)(arg2)) ;                  \
00143  } while(0)
00144 
00145 /*---------------------------------------------------------------------*/
00146 #define AFNI_CALL_VOID_3ARG(func,typ1,arg1,typ2,arg2,typ3,arg3)      \
00147  do{ void (*fp)(typ1,typ2,typ3) = (void (*)(typ1,typ2,typ3))(func) ; \
00148      if( fp != NULL )                                                \
00149       fp((typ1)(arg1),(typ2)(arg2),(typ3)(arg3)) ;                   \
00150  } while(0)
00151 
00152 /*-------------------------------------------------------------------------*/
00153 #define AFNI_CALL_VALU_3ARG(func,vtyp,vval,typ1,arg1,typ2,arg2,typ3,arg3) \
00154  do{ vtyp (*fp)(typ1,typ2,typ3) = (vtyp (*)(typ1,typ2,typ3))(func) ;      \
00155      if( fp != NULL )                                                     \
00156       (vval) = fp((typ1)(arg1),(typ2)(arg2),(typ3)(arg3)) ;               \
00157  } while(0)
00158 
00159 /*----------------------------------------------------------------------------*/
00160 #define AFNI_CALL_VOID_4ARG(func,typ1,arg1,typ2,arg2,typ3,arg3,typ4,arg4)     \
00161  do{ void (*fp)(typ1,typ2,typ3,typ4) = (void (*)(typ1,typ2,typ3,typ4))(func); \
00162      if( fp != NULL )                                                         \
00163       fp((typ1)(arg1),(typ2)(arg2),(typ3)(arg3),(typ4)(arg4)) ;               \
00164  } while(0)
00165 
00166 /*----------------------------------------------------------------------------------*/
00167 #define AFNI_CALL_VALU_4ARG(func,vtyp,vval,typ1,arg1,typ2,arg2,typ3,arg3,typ4,arg4) \
00168  do{ vtyp (*fp)(typ1,typ2,typ3,typ4) = (vtyp (*)(typ1,typ2,typ3,typ4))(func) ;      \
00169      if( fp != NULL )                                                               \
00170       (vval) = fp((typ1)(arg1),(typ2)(arg2),(typ3)(arg3),(typ4)(arg4)) ;            \
00171  } while(0)
00172 
00173 /*----------------------------------------------------------------------------------*/
00174 #define AFNI_CALL_VOID_7ARG(func,typ1,arg1,typ2,arg2,typ3,arg3,typ4,arg4,typ5,arg5,typ6,arg6,typ7,arg7) \
00175  do{ void (*fp)(typ1,typ2,typ3,typ4,typ5,typ6,typ7) = (void (*)(typ1,typ2,typ3,typ4,typ5,typ6,typ7))(func) ;      \
00176      if( fp != NULL )                                                               \
00177       fp((typ1)(arg1),(typ2)(arg2),(typ3)(arg3),(typ4)(arg4),(typ5)(arg5),(typ6)(arg6),(typ7)(arg7)) ;            \
00178  } while(0)
00179 
00180 /******************************************************************************/
00181 #endif /* _AFNI_AMALLOC_HEADER_ */
 

Powered by Plone

This site conforms to the following standards: