Changeset 12459
- Timestamp:
- 06/18/12 16:33:01 (13 years ago)
- Location:
- issm/trunk-jpl/src/c/Container
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified issm/trunk-jpl/src/c/Container/DataSet.cpp ¶
r12365 r12459 59 59 copy->presorted=presorted; 60 60 if(sorted_ids){ 61 copy->sorted_ids= (int*)xmalloc(objects.size()*sizeof(int));61 copy->sorted_ids=xNew<int>(objects.size()); 62 62 memcpy(copy->sorted_ids,sorted_ids,objects.size()*sizeof(int)); 63 63 } 64 64 if(id_offsets){ 65 copy->id_offsets= (int*)xmalloc(objects.size()*sizeof(int));65 copy->id_offsets=xNew<int>(objects.size()); 66 66 memcpy(copy->id_offsets,id_offsets,objects.size()*sizeof(int)); 67 67 } … … 80 80 DataSet::~DataSet(){ 81 81 clear(); 82 x free((void**)&sorted_ids);83 x free((void**)&id_offsets);82 xDelete<int>(sorted_ids); 83 xDelete<int>(id_offsets); 84 84 } 85 85 /*}}}*/ … … 221 221 222 222 /*Delete existing ids*/ 223 x free((void**)&sorted_ids);224 x free((void**)&id_offsets);223 xDelete<int>(sorted_ids); 224 xDelete<int>(id_offsets); 225 225 226 226 /*Allocate new ids*/ 227 sorted_ids= (int*)xmalloc(objects.size()*sizeof(int));228 id_offsets= (int*)xmalloc(objects.size()*sizeof(int));227 sorted_ids=xNew<int>(objects.size()); 228 id_offsets=xNew<int>(objects.size()); 229 229 230 230 /*Build id_offsets and sorted_ids*/ -
TabularUnified issm/trunk-jpl/src/c/Container/Elements.cpp ¶
r12365 r12459 215 215 #ifdef _HAVE_MPI_ 216 216 if(my_rank!=minrank){ 217 resultsenums= (int*)xmalloc(numberofresults*sizeof(int));218 resultssizes= (int*)xmalloc(numberofresults*sizeof(int));219 resultstimes= (double*)xmalloc(numberofresults*sizeof(double));220 resultssteps= (int*)xmalloc(numberofresults*sizeof(int));217 resultsenums=xNew<int>(numberofresults); 218 resultssizes=xNew<int>(numberofresults); 219 resultstimes=xNew<double>(numberofresults); 220 resultssteps=xNew<int>(numberofresults); 221 221 } 222 222 MPI_Bcast(resultsenums,numberofresults,MPI_INT,minrank,MPI_COMM_WORLD); … … 250 250 /*clean up*/ 251 251 xdelete(&vector); 252 x free((void**)&vector_serial);252 xDelete<double>(vector_serial); 253 253 } 254 254 } … … 269 269 270 270 /*Free ressources:*/ 271 x free((void**)&resultsenums);272 x free((void**)&resultssizes);273 x free((void**)&resultstimes);274 x free((void**)&resultssteps);271 xDelete<int>(resultsenums); 272 xDelete<int>(resultssizes); 273 xDelete<int>(resultssteps); 274 xDelete<double>(resultstimes); 275 275 delete patch; 276 276 } -
TabularUnified issm/trunk-jpl/src/c/Container/Nodes.cpp ¶
r12365 r12459 84 84 * cpus by the total last dofs of the previus cpu, starting from 0. 85 85 * First: get number of dofs for each cpu*/ 86 alldofcount= (int*)xmalloc(num_procs*sizeof(int));86 alldofcount=xNew<int>(num_procs); 87 87 #ifdef _HAVE_MPI_ 88 88 MPI_Gather(&dofcount,1,MPI_INT,alldofcount,1,MPI_INT,0,MPI_COMM_WORLD); … … 113 113 numnodes=this->NumberOfNodes(analysis_type); 114 114 if(numnodes*maxdofspernode){ 115 truedofs= (int*)xcalloc(numnodes*maxdofspernode,sizeof(int)); //initialize to 0, so that we can pick up the max116 alltruedofs= (int*)xcalloc(numnodes*maxdofspernode,sizeof(int));115 truedofs= xNewZeroInit<int>(numnodes*maxdofspernode); //initialize to 0, so that we can pick up the max 116 alltruedofs=xNewZeroInit<int>(numnodes*maxdofspernode); 117 117 } 118 118 … … 139 139 140 140 /* Free ressources: */ 141 x free((void**)&alldofcount);142 x free((void**)&truedofs);143 x free((void**)&alltruedofs);141 xDelete<int>(alldofcount); 142 xDelete<int>(truedofs); 143 xDelete<int>(alltruedofs); 144 144 } 145 145 /*}}}*/ … … 158 158 159 159 /*Allocate ranks: */ 160 ranks= (int*)xmalloc(numnodes*sizeof(int));161 minranks= (int*)xmalloc(numnodes*sizeof(int));160 ranks=xNew<int>(numnodes); 161 minranks=xNew<int>(numnodes); 162 162 163 163 for(i=0;i<numnodes;i++)ranks[i]=num_procs; //no cpu can have rank num_procs. This is the maximum limit. … … 190 190 191 191 /*Free ressources: */ 192 x free((void**)&ranks);193 x free((void**)&minranks);192 xDelete<int>(ranks); 193 xDelete<int>(minranks); 194 194 195 195 } -
TabularUnified issm/trunk-jpl/src/c/Container/Observations.cpp ¶
r12422 r12459 162 162 *pobs=observation->value; 163 163 } 164 x free((void**)&indices);164 xDelete<int>(indices); 165 165 166 166 }/*}}}*/ … … 189 189 this->quadtree->RangeSearch(&tempindices,&tempnobs,x_interp,y_interp,radius); 190 190 if(tempnobs){ 191 indices = (int*)xmalloc(tempnobs*sizeof(int));192 dists = (double*)xmalloc(tempnobs*sizeof(double));191 indices = xNew<int>(tempnobs); 192 dists = xNew<double>(tempnobs); 193 193 } 194 194 nobs = 0; … … 225 225 } 226 226 } 227 x free((void**)&dists);228 x free((void**)&tempindices);227 xDelete<double>(dists); 228 xDelete<int>(tempindices); 229 229 230 230 if(nobs){ 231 231 /*Allocate vectors*/ 232 x = (double*)xmalloc(nobs*sizeof(double));233 y = (double*)xmalloc(nobs*sizeof(double));234 obs = (double*)xmalloc(nobs*sizeof(double));232 x = xNew<double>(nobs); 233 y = xNew<double>(nobs); 234 obs = xNew<double>(nobs); 235 235 236 236 /*Loop over all observations and fill in x, y and obs*/ … … 242 242 243 243 /*Assign output pointer*/ 244 x free((void**)&indices);244 xDelete<int>(indices); 245 245 *px=x; 246 246 *py=y; … … 261 261 262 262 if(nobs){ 263 x = (double*)xmalloc(nobs*sizeof(double));264 y = (double*)xmalloc(nobs*sizeof(double));265 obs = (double*)xmalloc(nobs*sizeof(double));263 x = xNew<double>(nobs); 264 y = xNew<double>(nobs); 265 obs = xNew<double>(nobs); 266 266 for(int i=0;i<this->Size();i++){ 267 267 observation=(Observation*)this->GetObjectByOffset(i); … … 321 321 /*clean-up*/ 322 322 *pprediction = prediction; 323 x free((void**)&x);324 x free((void**)&y);325 x free((void**)&obs);323 xDelete<double>(x); 324 xDelete<double>(y); 325 xDelete<double>(obs); 326 326 }/*}}}*/ 327 327 /*FUNCTION Observations::InterpolationKriging{{{*/ … … 360 360 361 361 /*Allocate intermediary matrix and vectors*/ 362 Gamma = (double*)xmalloc(n_obs*n_obs*sizeof(double));363 gamma0 = (double*)xmalloc(n_obs*sizeof(double));364 ones = (double*)xmalloc(n_obs*sizeof(double));362 Gamma = xNew<double>(n_obs*n_obs); 363 gamma0 = xNew<double>(n_obs); 364 ones = xNew<double>(n_obs); 365 365 366 366 /*First: Create semivariogram matrix for observations*/ … … 401 401 *pprediction = prediction; 402 402 *perror = error; 403 x free((void**)&x);404 x free((void**)&y);405 x free((void**)&obs);406 x free((void**)&Gamma);407 x free((void**)&gamma0);408 x free((void**)&ones);409 x free((void**)&GinvG0);410 x free((void**)&Ginv1);411 x free((void**)&GinvZ);403 xDelete<double>(x); 404 xDelete<double>(y); 405 xDelete<double>(obs); 406 xDelete<double>(Gamma); 407 xDelete<double>(gamma0); 408 xDelete<double>(ones); 409 xDelete<double>(GinvG0); 410 xDelete<double>(Ginv1); 411 xDelete<double>(GinvZ); 412 412 413 413 }/*}}}*/ … … 445 445 Observation *observation2 = NULL; 446 446 447 double *counter = (double*)xmalloc(n*sizeof(double));447 double *counter = xNew<double>(n); 448 448 for(j=0;j<n;j++) counter[j] = 0.0; 449 449 for(j=0;j<n;j++) gamma[j] = 0.0; … … 474 474 475 475 /*Assign output pointer*/ 476 x free((void**)&counter);477 }/*}}}*/ 476 xDelete<double>(counter); 477 }/*}}}*/ -
TabularUnified issm/trunk-jpl/src/c/Container/Options.cpp ¶
r12365 r12459 222 222 else{ 223 223 stringsize=strlen(default_value)+1; 224 outstring= (char*)xmalloc(stringsize*sizeof(char));224 outstring=xNew<char>(stringsize); 225 225 memcpy(outstring,default_value,stringsize*sizeof(char)); 226 226 *pvalue=outstring; … … 246 246 if(option->ObjectEnum()==OptionCellEnum){ 247 247 if (option->NumEl()) { 248 *ppvalue= (char **) xmalloc(option->NumEl()*sizeof(char *));248 *ppvalue=xNew<char*>(option->NumEl()); 249 249 if (numel) *numel=option->NumEl(); 250 250 option->Get(&options); -
TabularUnified issm/trunk-jpl/src/c/Container/Vertices.cpp ¶
r12365 r12459 60 60 * cpus by the total last dofs of the previus cpu, starting from 0. 61 61 * First: bet number of dofs for each cpu*/ 62 alldofcount= (int*)xmalloc(num_procs*sizeof(int));62 alldofcount=xNew<int>(num_procs); 63 63 #ifdef _HAVE_MPI_ 64 64 MPI_Gather(&dofcount,1,MPI_INT,alldofcount,1,MPI_INT,0,MPI_COMM_WORLD); … … 83 83 * object that is not a clone, tell them to show their dofs, so that later on, they can get picked 84 84 * up by their clones: */ 85 truedofs = (int*)xcalloc(numberofobjects*numberofdofsperobject,sizeof(int));86 alltruedofs= (int*)xcalloc(numberofobjects*numberofdofsperobject,sizeof(int));85 truedofs =xNewZeroInit<int>(numberofobjects*numberofdofsperobject); 86 alltruedofs=xNewZeroInit<int>(numberofobjects*numberofdofsperobject); 87 87 for (i=0;i<this->Size();i++){ 88 88 Vertex* vertex=(Vertex*)this->GetObjectByOffset(i); … … 102 102 103 103 /* Free ressources: */ 104 x free((void**)&alldofcount);105 x free((void**)&truedofs);106 x free((void**)&alltruedofs);104 xDelete<int>(alldofcount); 105 xDelete<int>(truedofs); 106 xDelete<int>(alltruedofs); 107 107 } 108 108 /*}}}*/ … … 117 117 118 118 /*Allocate ranks: */ 119 ranks= (int*)xmalloc(numberofobjects*sizeof(int));120 minranks= (int*)xmalloc(numberofobjects*sizeof(int));119 ranks=xNew<int>(numberofobjects); 120 minranks=xNew<int>(numberofobjects); 121 121 122 122 for(i=0;i<numberofobjects;i++)ranks[i]=num_procs; //no cpu can have rank num_procs. This is the maximum limit. … … 143 143 144 144 /*Free ressources: */ 145 x free((void**)&ranks);146 x free((void**)&minranks);145 xDelete<int>(ranks); 146 xDelete<int>(minranks); 147 147 148 148 }
Note:
See TracChangeset
for help on using the changeset viewer.