Ignore:
Timestamp:
Mar 10, 2000, 4:23:01 PM (26 years ago)
Author:
ansari
Message:

Ajout de l'argument bool zero ds NDataBlock<T>::Alloc()
Fonction pour construire un message d'exception avec num de ligne et
nom de fichier ds pexceptions.h .cc

Reza 10/3/2000

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaLib/BaseTools/ndatablock.cc

    r754 r773  
    3030#endif
    3131
    32 Alloc(n);
     32Alloc(n, NULL, NULL, true);   // allocation et mise a zero
    3333}
    3434
     
    9696
    9797template <class T>
    98 void NDataBlock<T>::Alloc(size_t n,T* data,Bridge* br)
     98void NDataBlock<T>::Alloc(size_t n,T* data,Bridge* br,bool zero)
    9999// Allocation d'un NOUVEL espace de stoquage de "n" donnees
    100 // Si data==NULL : allocation de l'espace memoire (remplit de zeros)
     100// Si data==NULL : allocation de l'espace memoire
     101//    si zero == true , l'espace est remplis de zeros
    101102//    data!=NULL : partage des donnees avec l'adresse data
    102103// Si br==NULL   : les donnees nous appartiennent
     
    173174mSRef->nref = 1;
    174175if(data) mSRef->data = data;
    175 else {mSRef->data = new T[n]; memset(mSRef->data,0,n*sizeof(T));}
     176else {mSRef->data = new T[n]; if (zero) memset(mSRef->data,0,n*sizeof(T));}
    176177mSRef->bridge = br;
    177178
     
    201202if(&a==NULL) throw(NullPtrError("NDataBlock::Clone  &a==NULL\n"));
    202203if(!a.mSRef || a.mSz==0) throw(SzMismatchError("NDataBlock::Clone a.mSz==0\n"));
    203 Alloc(a.mSz);
     204Alloc(a.mSz, NULL, NULL, false);  // pas de mise a zero
    204205memcpy(Data(),a.Data(),mSz*sizeof(T));
    205206}
     
    288289if(data==NULL) throw(NullPtrError("NDataBlock::FillFrom  data==NULL\n"));
    289290if(n==0) throw(ParmError("NDataBlock::FillFrom  n<=0\n"));
    290 if(mSRef==NULL) Alloc(n);
     291if(mSRef==NULL) Alloc(n, NULL, NULL, false);  // Pas de mise a zero
    291292if(mSz<n) n = mSz;
    292293memcpy(Data(),data,n*sizeof(T));
Note: See TracChangeset for help on using the changeset viewer.