Changeset 12457
- Timestamp:
- 06/18/12 16:18:42 (13 years ago)
- Location:
- issm/trunk-jpl/src/c/objects
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/objects/DakotaPlugin.cpp
r12446 r12457 74 74 } 75 75 /*The descriptors: */ 76 variable_descriptors= (char**)xmalloc(numACV*sizeof(char*));76 variable_descriptors=xNew<char*>(numACV); 77 77 for(i=0;i<numACV;i++){ 78 78 string label=xCLabels[i]; 79 variable_descriptor= (char*)xmalloc((strlen(label.c_str())+1)*sizeof(char));79 variable_descriptor=xNew<char>(strlen(label.c_str())+1); 80 80 memcpy(variable_descriptor,label.c_str(),(strlen(label.c_str())+1)*sizeof(char)); 81 81 … … 100 100 for(i=0;i<numACV;i++){ 101 101 variable_descriptor=variable_descriptors[i]; 102 x free((void**)&variable_descriptor);102 xDelete<char>(variable_descriptor); 103 103 } 104 x free((void**)&variable_descriptors);104 xDelete<char*>(variable_descriptors); 105 105 xDelete<IssmDouble>(responses); 106 106 -
issm/trunk-jpl/src/c/objects/DofIndexing.cpp
r12365 r12457 51 51 52 52 if(this->gsize>0){ 53 this->f_set= (bool*)xmalloc(this->gsize*sizeof(bool));54 this->s_set= (bool*)xmalloc(this->gsize*sizeof(bool));53 this->f_set=xNew<bool>(this->gsize); 54 this->s_set=xNew<bool>(this->gsize); 55 55 this->svalues=xNew<IssmDouble>(this->gsize); 56 if(in->doftype)this->doftype= (int*)xmalloc(this->gsize*sizeof(int));57 this->gdoflist= (int*)xmalloc(this->gsize*sizeof(int));56 if(in->doftype)this->doftype=xNew<int>(this->gsize); 57 this->gdoflist=xNew<int>(this->gsize); 58 58 } 59 59 else{ … … 64 64 this->gdoflist=NULL; 65 65 } 66 if(this->fsize>0 && this->fsize!=UNDEF)this->fdoflist= (int*)xmalloc(this->fsize*sizeof(int)); else this->fdoflist=NULL;67 if(this->ssize>0 && this->ssize!=UNDEF)this->sdoflist= (int*)xmalloc(this->ssize*sizeof(int)); else this->sdoflist=NULL;66 if(this->fsize>0 && this->fsize!=UNDEF)this->fdoflist=xNew<int>(this->fsize); else this->fdoflist=NULL; 67 if(this->ssize>0 && this->ssize!=UNDEF)this->sdoflist=xNew<int>(this->ssize); else this->sdoflist=NULL; 68 68 69 69 if(this->gsize>0){ … … 82 82 DofIndexing::~DofIndexing(){ //destructor 83 83 84 x free((void**)&f_set);85 x free((void**)&s_set);84 xDelete<bool>(f_set); 85 xDelete<bool>(s_set); 86 86 xDelete<IssmDouble>(svalues); 87 x free((void**)&doftype);88 x free((void**)&gdoflist);89 x free((void**)&fdoflist);90 x free((void**)&sdoflist);87 xDelete<int>(doftype); 88 xDelete<int>(gdoflist); 89 xDelete<int>(fdoflist); 90 xDelete<int>(sdoflist); 91 91 92 92 } … … 102 102 /*allocate: */ 103 103 if(this->gsize>0){ 104 this->f_set= (bool*)xmalloc(this->gsize*sizeof(bool));105 this->s_set= (bool*)xmalloc(this->gsize*sizeof(bool));104 this->f_set=xNew<bool>(this->gsize); 105 this->s_set=xNew<bool>(this->gsize); 106 106 this->svalues=xNew<IssmDouble>(this->gsize); 107 if(in_doftype)this->doftype= (int*)xmalloc(this->gsize*sizeof(int));108 this->gdoflist= (int*)xmalloc(this->gsize*sizeof(int));107 if(in_doftype)this->doftype=xNew<int>(this->gsize); 108 this->gdoflist=xNew<int>(this->gsize); 109 109 } 110 110 … … 131 131 for(i=0;i<this->gsize;i++) if(f_set[i])size++; 132 132 this->fsize=size; 133 x free((void**)&this->fdoflist);134 if(this->fsize)this->fdoflist= (int*)xmalloc(size*sizeof(int));133 xDelete<int>(this->fdoflist); 134 if(this->fsize)this->fdoflist=xNew<int>(size); 135 135 else this->fdoflist=NULL; 136 136 } … … 139 139 for(i=0;i<this->gsize;i++) if(s_set[i])size++; 140 140 this->ssize=size; 141 x free((void**)&this->sdoflist);142 if(this->ssize)this->sdoflist= (int*)xmalloc(size*sizeof(int));141 xDelete<int>(this->sdoflist); 142 if(this->ssize)this->sdoflist=xNew<int>(size); 143 143 else this->sdoflist=NULL; 144 144 } -
issm/trunk-jpl/src/c/objects/FemModel.cpp
r12389 r12457 39 39 40 40 /*Dynamically allocate whatever is a list of length nummodels: */ 41 analysis_type_list= (int*)xmalloc(nummodels*sizeof(int));41 analysis_type_list=xNew<int>(nummodels); 42 42 43 43 /*Initialize: */ … … 85 85 86 86 /*Delete all the datasets: */ 87 x free((void**)&analysis_type_list);87 xDelete<int>(analysis_type_list); 88 88 delete elements; 89 89 delete nodes; -
issm/trunk-jpl/src/c/objects/Hook.cpp
r12365 r12457 47 47 else{ 48 48 /*Allocate: */ 49 this->objects= (Object**)xmalloc(this->num*sizeof(Object*));50 this->ids= (int*)xmalloc(this->num*sizeof(int));51 this->offsets= (int*)xmalloc(this->num*sizeof(int));49 this->objects=xNew<Object*>(this->num); 50 this->ids=xNew<int>(this->num); 51 this->offsets=xNew<int>(this->num); 52 52 53 53 /*Copy ids: */ … … 63 63 Hook::~Hook(){ 64 64 /*deallocate: */ 65 x free((void**)&this->objects);66 x free((void**)&this->ids);67 x free((void**)&this->offsets);65 xDelete<Object*>(this->objects); 66 xDelete<int>(this->ids); 67 xDelete<int>(this->offsets); 68 68 return; 69 69 } … … 132 132 output->num=this->num; 133 133 if(output->num){ 134 output->objects= (Object**)xmalloc(output->num*sizeof(Object*));135 output->ids= (int*)xmalloc(output->num*sizeof(int));136 output->offsets= (int*)xmalloc(output->num*sizeof(int));134 output->objects=xNew<Object*>(output->num); 135 output->ids=xNew<int>(output->num); 136 output->offsets=xNew<int>(output->num); 137 137 } 138 138 … … 252 252 if(output->num<1) _error_("Trying to spawn an empty ElementProperties!"); 253 253 254 output->objects= (Object**)xmalloc(output->num*sizeof(Object*));255 output->ids= (int*)xmalloc(output->num*sizeof(int));256 output->offsets= (int*)xmalloc(output->num*sizeof(int));254 output->objects=xNew<Object*>(output->num); 255 output->ids=xNew<int>(output->num); 256 output->offsets=xNew<int>(output->num); 257 257 258 258 for(i=0;i<output->num;i++){ -
issm/trunk-jpl/src/c/objects/IoModel.cpp
r12450 r12457 53 53 54 54 /*Initialize data: */ 55 this->data= (IssmPDouble**)xmalloc(MaximumNumberOfEnums*sizeof(IssmPDouble*));55 this->data=xNew<IssmPDouble*>(MaximumNumberOfEnums); 56 56 for(int i=0;i<MaximumNumberOfEnums;i++) this->data[i]=NULL; 57 57 … … 84 84 #endif 85 85 86 x free((void**)&this->data);87 x free((void**)&this->my_elements);88 x free((void**)&this->my_nodes);89 x free((void**)&this->my_vertices);90 x free((void**)&this->singlenodetoelementconnectivity);91 x free((void**)&this->numbernodetoelementconnectivity);86 xDelete<IssmPDouble*>(this->data); 87 xDelete<bool>(this->my_elements); 88 xDelete<bool>(this->my_nodes); 89 xDelete<int>(this->my_vertices); 90 xDelete<int>(this->singlenodetoelementconnectivity); 91 xDelete<int>(this->numbernodetoelementconnectivity); 92 92 } 93 93 /*}}}*/ … … 305 305 306 306 if(string_size){ 307 string= (char*)xmalloc((string_size+1)*sizeof(char));307 string=xNew<char>(string_size+1); 308 308 string[string_size]='\0'; 309 309 … … 315 315 } 316 316 else{ 317 string= (char*)xmalloc(sizeof(char));317 string=xNew<char>(1); 318 318 string[0]='\0'; 319 319 } … … 323 323 324 324 /*Free string*/ 325 x free((void**)&string);325 xDelete<char>(string); 326 326 327 327 break; … … 404 404 MPI_Bcast(&string_size,1,MPI_INT,0,MPI_COMM_WORLD); 405 405 if(string_size){ 406 string= (char*)xmalloc((string_size+1)*sizeof(char));406 string=xNew<char>((string_size+1)); 407 407 string[string_size]='\0'; 408 408 … … 411 411 } 412 412 else{ 413 string= (char*)xmalloc(sizeof(char));413 string=xNew<char>(1); 414 414 string[0]='\0'; 415 415 } … … 418 418 419 419 /*Free string*/ 420 x free((void**)&string);420 xDelete<char>(string); 421 421 422 422 break; … … 559 559 /*Now allocate string: */ 560 560 if(string_size){ 561 string= (char*)xmalloc((string_size+1)*sizeof(char));561 string=xNew<char>((string_size+1)); 562 562 string[string_size]='\0'; 563 563 … … 571 571 } 572 572 else{ 573 string= (char*)xmalloc(sizeof(char));573 string=xNew<char>(1); 574 574 string[0]='\0'; 575 575 } … … 621 621 /*Now allocate matrix: */ 622 622 if(M*N){ 623 matrix= (IssmPDouble*)xmalloc(M*N*sizeof(IssmPDouble));623 matrix=xNew<IssmPDouble>(M*N); 624 624 625 625 /*Read matrix on node 0, then broadcast: */ … … 635 635 /*Now cast to integer: */ 636 636 if(M*N){ 637 integer_matrix= (int*)xmalloc(M*N*sizeof(int));637 integer_matrix=xNew<int>(M*N); 638 638 for (i=0;i<M;i++){ 639 639 for (j=0;j<N;j++){ … … 646 646 } 647 647 /*Free ressources:*/ 648 x free((void**)&matrix);648 xDelete<IssmPDouble>(matrix); 649 649 650 650 /*Assign output pointers: */ … … 740 740 /*Now allocate string array: */ 741 741 if(numstrings){ 742 strings= (char**)xmalloc(numstrings*sizeof(char*));742 strings=xNew<char*>(numstrings); 743 743 for(i=0;i<numstrings;i++)strings[i]=NULL; 744 744 … … 753 753 #endif 754 754 if(string_size){ 755 string= (char*)xmalloc((string_size+1)*sizeof(char));755 string=xNew<char>((string_size+1)); 756 756 string[string_size]='\0'; 757 757 … … 765 765 } 766 766 else{ 767 string= (char*)xmalloc(sizeof(char));767 string=xNew<char>(1); 768 768 string[0]='\0'; 769 769 } … … 812 812 813 813 /*Allocate matrices :*/ 814 matrices= (IssmPDouble**)xmalloc(numrecords*sizeof(IssmPDouble*));815 mdims= (int*)xmalloc(numrecords*sizeof(int));816 ndims= (int*)xmalloc(numrecords*sizeof(int));814 matrices=xNew<IssmPDouble*>(numrecords); 815 mdims=xNew<int>(numrecords); 816 ndims=xNew<int>(numrecords); 817 817 818 818 for(i=0;i<numrecords;i++){ … … 841 841 /*Now allocate matrix: */ 842 842 if(M*N){ 843 matrix= (IssmPDouble*)xmalloc(M*N*sizeof(IssmPDouble));843 matrix=xNew<IssmPDouble>(M*N); 844 844 845 845 /*Read matrix on node 0, then broadcast: */ … … 886 886 case 3: {//IssmPDouble 887 887 IssmPDouble *value = NULL; 888 value= (IssmPDouble*)xmalloc(1*sizeof(IssmPDouble));888 value=xNew<IssmPDouble>(1); 889 889 FetchData(value,index+1); 890 890 option = new OptionDouble(); … … 1142 1142 } 1143 1143 /*Free ressources:*/ 1144 x free((void**)&IssmPDoublevector);1145 x free((void**)&string);1144 xDelete<IssmPDouble>(IssmPDoublevector); 1145 xDelete<char>(string); 1146 1146 } 1147 1147 /*FUNCTION IoModel::LastIndex{{{*/ -
issm/trunk-jpl/src/c/objects/Node.cpp
r12365 r12457 801 801 if(setenum==FsetEnum){ 802 802 if(this->indexing.fsize){ 803 indices= (int*)xmalloc(this->indexing.fsize*sizeof(int));803 indices=xNew<int>(this->indexing.fsize); 804 804 values=xNew<IssmDouble>(this->indexing.fsize); 805 805 … … 819 819 else if(setenum==SsetEnum){ 820 820 if(this->indexing.ssize){ 821 indices= (int*)xmalloc(this->indexing.ssize*sizeof(int));821 indices=xNew<int>(this->indexing.ssize); 822 822 values=xNew<IssmDouble>(this->indexing.ssize); 823 823 … … 839 839 /*Free ressources:*/ 840 840 xDelete<IssmDouble>(values); 841 x free((void**)&indices);841 xDelete<int>(indices); 842 842 } 843 843 /*}}}*/
Note:
See TracChangeset
for help on using the changeset viewer.