]> Creatis software - gdcm.git/blobdiff - src/gdcmUtil.cxx
BUG: Solve JP feature, and at the same time avoid allocating a billion time the very...
[gdcm.git] / src / gdcmUtil.cxx
index fcaf873afc2f330b5c2b9f6c2757756915e7ddae..05c33b49f23f319226ead6b018e18cef60ca503c 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmUtil.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/02/14 14:34:27 $
-  Version:   $Revision: 1.141 $
+  Date:      $Date: 2005/02/14 15:52:39 $
+  Version:   $Revision: 1.143 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -871,7 +871,6 @@ std::ostream &binary_write(std::ostream &os, const char *val)
  * \brief
  * @param os ostream to write to
  * @param val val
- * @param len length of the 'value' to be written  
  */ 
 std::ostream &binary_write(std::ostream &os, std::string const &val)
 {
@@ -881,7 +880,8 @@ std::ostream &binary_write(std::ostream &os, std::string const &val)
 /**
  * \brief  binary_write binary_write
  * @param os ostream to write to
- * @param val val
+ * @param val value
+ * @param len length of the 'value' to be written
  */ 
 std::ostream &binary_write(std::ostream &os, const uint8_t *val, size_t len)
 {
@@ -904,7 +904,7 @@ std::ostream &binary_write(std::ostream &os, const uint16_t *val, size_t len)
 #if defined(GDCM_WORDS_BIGENDIAN) || defined(GDCM_FORCE_BIGENDIAN_EMULATION)
    const int BUFFER_SIZE = 4096;
    uint16_t *binArea16 = (uint16_t*)val;
-   uint16_t *buffer    = new uint16_t[BUFFER_SIZE/2];
+   static uint16_t buffer[BUFFER_SIZE/2];
    uint16_t *pbuffer   = buffer;
  
    // how many BUFFER_SIZE long pieces in binArea ?
@@ -922,7 +922,7 @@ std::ostream &binary_write(std::ostream &os, const uint16_t *val, size_t len)
         //   1) Save 1 affectation and 2 AND operations
         //       buffer[i] =  (binArea16[i] >> 8) | (binArea16[i] << 8);
         //   2) Replace * operations by + operations using pointers
-         *pbuffer = *binArea16 >> 8 | *binArea16 >> 8;
+         *pbuffer = *binArea16 >> 8 | *binArea16 << 8;
          pbuffer++;
          binArea16++;
       }
@@ -941,7 +941,6 @@ std::ostream &binary_write(std::ostream &os, const uint16_t *val, size_t len)
       }
       os.write ( (char*)buffer, remainingSize );
    }
-   delete[] buffer;
    return os;
 #else
    return os.write(reinterpret_cast<const char*>(val), len);