Changeset 12451
- Timestamp:
- 06/18/12 15:33:50 (13 years ago)
- Location:
- issm/trunk-jpl/src/c
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/modules/ModelProcessorx/Dakota/CreateParametersDakota.cpp
r12450 r12451 136 136 137 137 /*Free ressources:*/ 138 xDelete< int>(dakota_parameter);138 xDelete<double>(dakota_parameter); 139 139 } 140 140 } … … 214 214 xDelete<char*>(variabledescriptors); 215 215 xDelete<int>(part); 216 xDelete< int>(dpart);216 xDelete<double>(dpart); 217 217 xDelete<char>(qmuinname); 218 218 xDelete<char>(qmuerrname); -
issm/trunk-jpl/src/c/objects/Params/DoubleMatArrayParam.cpp
r12365 r12451 36 36 M=in_M; 37 37 if(M){ 38 array= (double**)xmalloc(M*sizeof(double*));39 mdim_array= (int*)xmalloc(M*sizeof(int));40 ndim_array= (int*)xmalloc(M*sizeof(int));38 array=xNew<double*>(M); 39 mdim_array=xNew<int>(M); 40 ndim_array=xNew<int>(M); 41 41 42 42 for(i=0;i<M;i++){ … … 48 48 49 49 if(m*n){ 50 matrix= (double*)xmalloc(m*n*sizeof(double));50 matrix=xNew<double>(m*n); 51 51 memcpy(matrix,in_array[i],m*n*sizeof(double)); 52 52 } … … 70 70 double* matrix=NULL; 71 71 72 x free((void**)&mdim_array);73 x free((void**)&ndim_array);72 xDelete<int>(mdim_array); 73 xDelete<int>(ndim_array); 74 74 75 75 for(i=0;i<M;i++){ 76 76 matrix=array[i]; 77 x free((void**)&matrix);78 } 79 80 x free((void**)&array);77 xDelete<double>(matrix); 78 } 79 80 xDelete<double*>(array); 81 81 return; 82 82 } … … 159 159 out_M=this->M; 160 160 if(out_M){ 161 out_array= (double**)xmalloc(M*sizeof(double*));162 out_mdim_array= (int*)xmalloc(M*sizeof(int));163 out_ndim_array= (int*)xmalloc(M*sizeof(int));161 out_array=xNew<double*>(M); 162 out_mdim_array=xNew<int>(M); 163 out_ndim_array=xNew<int>(M); 164 164 165 165 memcpy(out_mdim_array,this->mdim_array,M*sizeof(int)); … … 172 172 173 173 if(m*n){ 174 out_matrix= (double*)xmalloc(m*n*sizeof(double));174 out_matrix=xNew<double>(m*n); 175 175 memcpy(out_matrix,matrix,m*n*sizeof(double)); 176 176 } … … 209 209 210 210 /*avoid leak: */ 211 x free((void**)&mdim_array);212 x free((void**)&ndim_array);211 xDelete<int>(mdim_array); 212 xDelete<int>(ndim_array); 213 213 for(i=0;i<M;i++){ 214 214 matrix=array[i]; 215 x free((void**)&matrix);216 } 217 x free((void**)&array);215 xDelete<double>(matrix); 216 } 217 xDelete<double*>(array); 218 218 219 219 /*copy data: */ 220 220 this->M=in_M; 221 this->array= (double**)xmalloc(M*sizeof(double*));222 this->mdim_array= (int*)xmalloc(M*sizeof(int));223 this->ndim_array= (int*)xmalloc(M*sizeof(int));221 this->array=xNew<double*>(M); 222 this->mdim_array=xNew<int>(M); 223 this->ndim_array=xNew<int>(M); 224 224 225 225 memcpy(this->mdim_array,in_mdim_array,M*sizeof(double)); … … 231 231 n=in_ndim_array[i]; 232 232 233 matrix= (double*)xmalloc(m*n*sizeof(double));233 matrix=xNew<double>(m*n); 234 234 memcpy(matrix,in_matrix,m*n*sizeof(double)); 235 235 -
issm/trunk-jpl/src/c/objects/Params/DoubleMatParam.cpp
r12365 r12451 33 33 N=in_N; 34 34 35 value= (double*)xmalloc(M*N*sizeof(double));35 value=xNew<double>(M*N); 36 36 memcpy(value,in_value,M*N*sizeof(double)); 37 37 } … … 98 98 double* output=NULL; 99 99 100 output= (double*)xmalloc((int)(M*N*sizeof(double)));100 output=xNew<double>(M*N); 101 101 memcpy(output,value,M*N*sizeof(double)); 102 102 … … 123 123 xfree((void**)&this->value); 124 124 125 this->value= (double*)xmalloc(in_M*in_N*sizeof(double));125 this->value=xNew<double>(in_M*in_N); 126 126 memcpy(this->value,doublearray,in_M*in_N*sizeof(double)); 127 127 -
issm/trunk-jpl/src/c/objects/Params/IntMatParam.cpp
r12365 r12451 33 33 N=in_N; 34 34 35 value= (int*)xmalloc(M*N*sizeof(int));35 value=xNew<int>(M*N); 36 36 memcpy(value,in_value,M*N*sizeof(int)); 37 37 } … … 39 39 /*FUNCTION IntMatParam::~IntMatParam(){{{*/ 40 40 IntMatParam::~IntMatParam(){ 41 x free((void**)&value);41 xDelete<int>(value); 42 42 return; 43 43 } … … 98 98 int* output=NULL; 99 99 100 output= (int*)xmalloc((int)(M*N*sizeof(int)));100 output=xNew<int>(M*N); 101 101 memcpy(output,value,M*N*sizeof(int)); 102 102 … … 116 116 117 117 /*avoid leak: */ 118 x free((void**)&this->value);118 xDelete<int>(this->value); 119 119 120 this->value= (int*)xmalloc(in_M*in_N*sizeof(int));120 this->value=xNew<int>(in_M*in_N); 121 121 memcpy(this->value,intarray,in_M*in_N*sizeof(int)); 122 122 -
issm/trunk-jpl/src/c/objects/Params/IntVecParam.cpp
r12365 r12451 33 33 34 34 if(M){ 35 values= (int*)xmalloc(M*sizeof(int));35 values=xNew<int>(M); 36 36 memcpy(values,in_values,M*sizeof(int)); 37 37 } … … 46 46 47 47 if(M){ 48 values= (int*)xmalloc(M*sizeof(int));48 values=xNew<int>(M); 49 49 for(int i=0;i<in_M;i++) values[i]=(int)in_values[i]; 50 50 } … … 54 54 /*FUNCTION IntVecParam::~IntVecParam(){{{*/ 55 55 IntVecParam::~IntVecParam(){ 56 x free((void**)&values);56 xDelete<int>(values); 57 57 return; 58 58 } … … 112 112 113 113 if(M){ 114 output= (int*)xmalloc(M*sizeof(int));114 output=xNew<int>(M); 115 115 memcpy(output,values,M*sizeof(int)); 116 116 } … … 130 130 131 131 /*avoid leak: */ 132 x free((void**)&this->values);132 xDelete<int>(this->values); 133 133 134 134 if(in_M){ 135 this->values= (int*)xmalloc(in_M*sizeof(int));135 this->values=xNew<int>(in_M); 136 136 memcpy(this->values,intarray,in_M*sizeof(int)); 137 137 } -
issm/trunk-jpl/src/c/objects/Params/StringArrayParam.cpp
r12365 r12451 36 36 37 37 if(numstrings){ 38 value= (char**)xmalloc(numstrings*sizeof(char*));38 value=xNew<char*>(numstrings); 39 39 for(i=0;i<numstrings;i++){ 40 40 char* string=NULL; 41 41 size=strlen(in_values[i])+1; 42 string= (char*)xmalloc(size*sizeof(char));42 string=xNew<char>(size); 43 43 memcpy(string,in_values[i],size*sizeof(char)); 44 44 value[i]=string; … … 57 57 for(i=0;i<this->numstrings;i++){ 58 58 string=value[i]; 59 x free((void**)&string);59 xDelete<char>(string); 60 60 } 61 x free((void**)&value);61 xDelete<char*>(value); 62 62 } 63 63 /*}}}*/ … … 120 120 M=this->numstrings; 121 121 if(this->numstrings){ 122 outstrings= (char**)xmalloc(this->numstrings*sizeof(char*));122 outstrings=xNew<char*>(this->numstrings); 123 123 124 124 for(i=0;i<this->numstrings;i++){ … … 126 126 stringsize=strlen(string)+1; 127 127 128 string2= (char*)xmalloc(stringsize*sizeof(char));128 string2=xNew<char>(stringsize); 129 129 memcpy(string2,string,stringsize*sizeof(char)); 130 130 … … 155 155 for(i=0;i<this->numstrings;i++){ 156 156 string=this->value[i]; 157 x free((void**)&string);157 xDelete<char>(string); 158 158 } 159 x free((void**)&this->value);159 xDelete<char*>(this->value); 160 160 161 161 /*copy: */ 162 162 this->numstrings=M; 163 this->value= (char**)xmalloc(this->numstrings*sizeof(char*));163 this->value=xNew<char*>(this->numstrings); 164 164 for(i=0;i<this->numstrings;i++){ 165 165 string=stringarray[i]; 166 166 stringsize=strlen(string)+1; 167 167 168 string2= (char*)xmalloc(stringsize*sizeof(char));168 string2=xNew<char>(stringsize); 169 169 memcpy(string2,string,stringsize*sizeof(char)); 170 170 -
issm/trunk-jpl/src/c/objects/Params/StringParam.cpp
r12365 r12451 30 30 31 31 enum_type=in_enum_type; 32 value= (char*)xmalloc((strlen(in_value)+1)*sizeof(char));32 value=xNew<char>(strlen(in_value)+1); 33 33 memcpy(value,in_value,(strlen(in_value)+1)*sizeof(char)); 34 34 … … 38 38 /*FUNCTION StringParam::~StringParam(){{{*/ 39 39 StringParam::~StringParam(){ 40 x free((void**)&value);40 xDelete<char>(value); 41 41 } 42 42 /*}}}*/ … … 88 88 stringsize=strlen(this->value)+1; 89 89 90 outstring= (char*)xmalloc(stringsize*sizeof(char));90 outstring=xNew<char>(stringsize); 91 91 memcpy(outstring,this->value,stringsize*sizeof(char)); 92 92 … … 106 106 107 107 /*avoid leak: */ 108 x free((void**)&this->value);108 xDelete<char>(this->value); 109 109 110 110 /*copy: */ 111 111 stringsize=strlen(string)+1; 112 this->value= (char*)xmalloc(stringsize*sizeof(char));112 this->value=xNew<char>(stringsize); 113 113 memcpy(this->value,string,stringsize*sizeof(char)); 114 114
Note:
See TracChangeset
for help on using the changeset viewer.