Index: trunk/SophyaLib/HiStats/histerr.cc
===================================================================
--- trunk/SophyaLib/HiStats/histerr.cc	(revision 2618)
+++ trunk/SophyaLib/HiStats/histerr.cc	(revision 2619)
@@ -44,6 +44,7 @@
 HistoErr::~HistoErr(void)
 {
- if(mNData) {delete [] mNData; mNData=NULL;}
-}
+ Delete();
+}
+
 /********* Methode *********/
 /*! Allocation du tableau mNData */
@@ -56,4 +57,12 @@
 
 /********* Methode *********/
+/*! Delete des tableaux */
+void HistoErr::Delete(void)
+{
+ Histo::Delete();
+ if(mNData) {delete [] mNData; mNData=NULL;}
+}
+
+/********* Methode *********/
 /*!
   Remise a zero
@@ -61,6 +70,6 @@
 void HistoErr::Zero(void)
 {
- if(mNData != NULL) memset(mNData,0,mBins*sizeof(uint_4));
  Histo::Zero();
+ if(mNData) memset(mNData,0,mBins*sizeof(uint_4));
 }
 
@@ -172,4 +181,23 @@
 }
 
+/********* Methode *********/
+/*!
+  Operateur egal HistoErr = HistoErr
+*/
+HistoErr& HistoErr::operator = (const HistoErr& h)
+{
+  if(this==&h) return *this;
+  Delete();
+  if(h.mBins<=0) return *this;
+
+  // Copy the "Histo" part
+  (Histo)(*this) = Histo::operator=(h);
+  // Copy the "entries by bin" table
+  allocate_mNData(h.mBins);
+  memcpy(mNData,h.mNData,mBins*sizeof(uint_4));
+
+  return *this;
+}
+
 ///////////////////////////////////////////////////////////
 // --------------------------------------------------------
Index: trunk/SophyaLib/HiStats/histerr.h
===================================================================
--- trunk/SophyaLib/HiStats/histerr.h	(revision 2618)
+++ trunk/SophyaLib/HiStats/histerr.h	(revision 2619)
@@ -44,6 +44,11 @@
   void ToCorrel(void);
 
+  // Operators
+  HistoErr& operator = (const HistoErr& h);
+
 protected:
   void allocate_mNData(int nbin);
+  void Delete(void);
+
   uint_4* mNData;    //!< nombre d'entrees dans chaque bin
 };
Index: trunk/SophyaLib/HiStats/histos.cc
===================================================================
--- trunk/SophyaLib/HiStats/histos.cc	(revision 2618)
+++ trunk/SophyaLib/HiStats/histos.cc	(revision 2619)
@@ -1,4 +1,4 @@
 //
-// $Id: histos.cc,v 1.18 2004-09-10 09:52:19 cmv Exp $
+// $Id: histos.cc,v 1.19 2004-09-15 15:36:54 cmv Exp $
 //
 
@@ -57,16 +57,12 @@
 Histo::Histo(const Histo& H)
 : mData((H.mBins>0)? new r_8[H.mBins] : NULL),
-  mErr2(NULL),
+  mErr2((H.mBins>0 && H.mErr2!=NULL)? new r_8[H.mBins]: NULL),
   mUnder(H.mUnder), mOver(H.mOver), nHist(H.nHist), nEntries(H.nEntries),
   mBins(H.mBins), mMin(H.mMin), mMax(H.mMax),
   binWidth(H.binWidth)
 {
-  if(mBins>0) {
-    memcpy(mData, H.mData, mBins*sizeof(r_8));
-    if( H.mErr2 != NULL ) {
-      mErr2 = new r_8[mBins];
-      memcpy(mErr2, H.mErr2, mBins*sizeof(r_8));
-    }
-  }
+  if(mBins<=0) return;
+  memcpy(mData,H.mData,mBins*sizeof(r_8));
+  if(H.mErr2) memcpy(mErr2, H.mErr2, mBins*sizeof(r_8));
 }
 
@@ -95,10 +91,10 @@
 void Histo::Zero()
 {
-  if(mBins<=0) return;
-  memset(mData, 0, mBins*sizeof(r_8));
+  if(mBins<=0 || mData==NULL) return;
+  memset(mData,0,mBins*sizeof(r_8));
   mUnder = mOver = 0;
   nHist = 0;
   nEntries = 0;
-  if( mErr2 != NULL ) memset(mErr2, 0, mBins*sizeof(r_8));
+  if(mErr2) memset(mErr2, 0, mBins*sizeof(r_8));
 }
 
@@ -111,5 +107,5 @@
  if(mBins<=0) return;
  if(mErr2==NULL) mErr2 = new r_8[mBins];
- memset(mErr2, 0, mBins*sizeof(r_8));
+ memset(mErr2,0,mBins*sizeof(r_8));
 }
 
@@ -121,10 +117,9 @@
 {
   if(this == &h) return *this;
-  if( h.mBins <= 0 ) {Delete(); return *this;}
-  if( h.mBins > mBins ) Delete();
-  if(!h.mErr2 && mErr2 ) { delete [] mErr2; mErr2=NULL;}
-  if(!mData) mData = new r_8[h.mBins];
-  if(h.mErr2 && !mErr2 ) mErr2 = new r_8[h.mBins];
-
+  Delete();
+  if(h.mBins<=0 || h.mData==NULL) return *this;
+
+  mData = new r_8[h.mBins];
+  if(h.mErr2) mErr2 = new r_8[h.mBins];
   mUnder = h.mUnder;
   mOver = h.mOver;
@@ -136,6 +131,6 @@
   binWidth = h.binWidth;
   
-  memcpy(mData, h.mData, mBins*sizeof(r_8));
-  if(mErr2) memcpy(mErr2, h.mErr2, mBins*sizeof(r_8));
+  memcpy(mData,h.mData,mBins*sizeof(r_8));
+  if(mErr2) memcpy(mErr2,h.mErr2,mBins*sizeof(r_8));
 
   return *this;
