source:
issm/oecreview/Archive/12321-12677/ISSM-12446-12447.diff
Last change on this file was 12679, checked in by , 13 years ago | |
---|---|
File size: 2.0 KB |
-
u/astrid-r1b/morlighe/issmuci/trunk-jpl/../trunk-jpl/src/c/shared/Alloc/xNewDelete.h
58 58 } 59 59 60 60 template <class T> 61 T* xReNew(T* old, unsigned int size) {61 T* xReNew(T* old, unsigned int old_size, unsigned int size) { 62 62 #ifdef USE_CXX_MEMORY_MANAGMENT_FOR_NON_POD_TYPES 63 assert(old); 64 T* aT_p=xNew<T>(size); 65 for (unsigned int i=0; i<size;++i) 66 aT_p[i]=old[i]; 67 xDelete<T>(old); 63 T* aT_p=NULL; 64 if (!old) { // no old memory 65 if (size) 66 aT_p=xNew<T>(size); 67 } 68 else { // have old memory 69 if (!size) // but 0 size 70 xDelete<T>(old); 71 else { // non-zero size 72 if (size>old_size) { // do something only if it is bigger 73 aT_p=xNew<T>(size); 74 for (unsigned int i=0; i<old_size;++i) 75 aT_p[i]=old[i]; // copy the items 76 xDelete<T>(old); 77 } 78 else // size is equal or less than old size 79 aT_p=old; // do nothing 80 } 81 } 68 82 return aT_p; 69 83 #else 70 84 T* aT_p=(T*)realloc((void*)old,size*sizeof(T)); -
u/astrid-r1b/morlighe/issmuci/trunk-jpl/../trunk-jpl/src/c/shared/TriMesh/TriMeshUtils.cpp
65 65 } 66 66 else{ 67 67 /*Reallocate another max_number_elements slots in the GridElements: */ 68 GridElementsRealloc=xReNew<int>(GridElements, (current_size+max_number_elements));68 GridElementsRealloc=xReNew<int>(GridElements,current_size,(current_size+max_number_elements)); 69 69 if (!GridElementsRealloc){ 70 70 noerr=0; 71 71 goto cleanup_and_return;
Note:
See TracBrowser
for help on using the repository browser.