Import Geant4 10.7.0 source tree
This commit is contained in:
@@ -7,8 +7,8 @@ namespace tools {
|
||||
|
||||
template <class T>
|
||||
inline bool realloc(T*& a_pointer,size_t a_new_size,size_t a_old_size,bool a_init = false) {
|
||||
if(!a_new_size) {
|
||||
delete [] a_pointer;
|
||||
if(!a_new_size) {
|
||||
delete [] a_pointer;
|
||||
a_pointer = 0;
|
||||
return true;
|
||||
}
|
||||
@@ -20,14 +20,14 @@ inline bool realloc(T*& a_pointer,size_t a_new_size,size_t a_old_size,bool a_ini
|
||||
if(a_old_size==a_new_size) return true;
|
||||
T* pointer = new T[a_new_size];
|
||||
if(!pointer) {
|
||||
delete [] a_pointer;
|
||||
delete [] a_pointer;
|
||||
a_pointer = 0;
|
||||
return false;
|
||||
}
|
||||
if(a_new_size>a_old_size) {
|
||||
::memcpy(pointer,a_pointer,a_old_size*sizeof(T));
|
||||
if(a_init){
|
||||
size_t num = a_new_size-a_old_size;
|
||||
size_t num = a_new_size-a_old_size;
|
||||
T* pos = pointer+a_old_size;
|
||||
for(size_t i=0;i<num;i++,pos++) *pos = T();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user