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  

dyn_array.h File Reference

#include <stdlib.h>

Go to the source code of this file.


Defines

#define DECLARE_ARRAY_TYPE(typ)   typedef struct { int num ; typ * ar ; } typ ## _array
#define DECLARE_ARRAY(anam, typ)   typ ## _array * anam
#define INIT_ARRAY(anam, typ)
#define ADDTO_ARRAY(anam, typ, val)
#define DELETE_ARRAY(anam)   do{ free(anam->ar) ; free(anam) ; anam = NULL ; } while(0)
#define KILL_ARRAY(anam, killer)
#define FREE_ARRAY(anam)   KILL_ARRAY(anam,free)

Define Documentation

#define ADDTO_ARRAY anam,
typ,
val   
 

Value:

do{ int n=anam->num ;                                          \
     anam->ar = realloc(anam->ar,sizeof(typ)*(n+1)) ;           \
     anam->ar[n] = (val) ; anam->num++ ;             } while(0)
Append element "val" to an array pointer "anam" of type "typ_array *".

Definition at line 52 of file dyn_array.h.

#define DECLARE_ARRAY anam,
typ       typ ## _array * anam
 

Declare a pointer of type "typ_array *".

Definition at line 42 of file dyn_array.h.

#define DECLARE_ARRAY_TYPE typ       typedef struct { int num ; typ * ar ; } typ ## _array
 

Declare an array type of "typ_array".

Definition at line 37 of file dyn_array.h.

#define DELETE_ARRAY anam       do{ free(anam->ar) ; free(anam) ; anam = NULL ; } while(0)
 

Delete the array pointed to by "anam".

Definition at line 59 of file dyn_array.h.

#define FREE_ARRAY anam       KILL_ARRAY(anam,free)
 

Apply free() to each element of the array pointed to by "anam", then delete anam itself.

Definition at line 74 of file dyn_array.h.

#define INIT_ARRAY anam,
typ   
 

Value:

do{ anam = malloc(sizeof(typ ## _array *)) ;                   \
     anam->num = 0 ; anam->ar = NULL ;       } while(0)
Initialize an array pointer of type "typ_array *".

Definition at line 46 of file dyn_array.h.

#define KILL_ARRAY anam,
killer   
 

Value:

do{ int i ;                                                    \
     for( i=0 ; i < anam->num ; i++ ) killer(anam->ar[i]) ;     \
     free(anam->ar) ; free(anam) ; anam = NULL ;                \
 } while(0)
Apply "killer()" to each element of the array pointed to by "anam", then delete anam itself.

Definition at line 65 of file dyn_array.h.

 

Powered by Plone

This site conforms to the following standards: