/vol/vipdata/irtk/common++/include/irtkDeallocate.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef _IRTKDEALLOCATE_H
00014
00015 #define _IRTKDEALLOCATE_H
00016
00017 #include <irtkCommon.h>
00018
00019 template <class Type> inline Type **Deallocate(Type **matrix)
00020 {
00021 delete []matrix[0];
00022 delete []matrix;
00023 matrix = NULL;
00024
00025 #ifdef DEBUG
00026 memory_allocated -= x*y*sizeof(Type);
00027 cout << "Deallocate: Memory allocated is " << memory_allocated << " bytes.\n";
00028 #endif
00029
00030 return NULL;
00031 }
00032
00033 template <class Type> inline Type ***Deallocate(Type ***matrix)
00034 {
00035 delete []matrix[0][0];
00036 delete []matrix[0];
00037 delete []matrix;
00038
00039 #ifdef DEBUG
00040 memory_allocated -= x*y*z*sizeof(Type);
00041 cout << "Deallocate: Memory allocated is " << memory_allocated << " bytes.\n";
00042 #endif
00043
00044 matrix = NULL;
00045 return NULL;
00046 }
00047
00048 template <class Type> inline Type ****Deallocate(Type ****matrix)
00049 {
00050 delete []matrix[0][0][0];
00051 delete []matrix[0][0];
00052 delete []matrix[0];
00053 delete []matrix;
00054
00055 matrix = NULL;
00056 return NULL;
00057 }
00058
00059 #endif