certi-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[certi-cvs] certi/libHLA HLAbuffer.hh


From: certi-cvs
Subject: [certi-cvs] certi/libHLA HLAbuffer.hh
Date: Sat, 22 Nov 2008 14:55:58 +0000

CVSROOT:        /sources/certi
Module name:    certi
Changes by:     Petr Gotthard <gotthardp>       08/11/22 14:55:58

Modified files:
        libHLA         : HLAbuffer.hh 

Log message:
        Adjacent __HLAbuffer structures caused failure of the __check_memory() 
function. [Wrong buffer was found by the std::lower_bound() function.]
        Occured on FreeBSD 7.0; reported by Martin Spott.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/certi/libHLA/HLAbuffer.hh?cvsroot=certi&r1=1.6&r2=1.7

Patches:
Index: HLAbuffer.hh
===================================================================
RCS file: /sources/certi/certi/libHLA/HLAbuffer.hh,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- HLAbuffer.hh        19 Nov 2008 10:25:05 -0000      1.6
+++ HLAbuffer.hh        22 Nov 2008 14:55:58 -0000      1.7
@@ -11,7 +11,7 @@
 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 // Lesser General Public License for more details.
 //
-// $Id: HLAbuffer.hh,v 1.6 2008/11/19 10:25:05 gotthardp Exp $
+// $Id: HLAbuffer.hh,v 1.7 2008/11/22 14:55:58 gotthardp Exp $
 // ----------------------------------------------------------------------------
 
 #ifndef _HLATYPES_BUFFER_HH
@@ -60,7 +60,7 @@
 {
 private:
     // static buffer for all instantiations of the HLAdata template
-    // indexed by pointers after the last element, the end() pointers
+    // indexed by "last pointers", i.e. pointers to the last byte in the buffer
     typedef std::map<char*,__HLAbuffer*> BufferList;
     static BufferList gBuffers;
 
@@ -96,7 +96,7 @@
         mCapacity = (size_t)(capacity*1.5);
         mBegin = (char*)calloc(1, mCapacity);
         // store "this" to a global table
-        gBuffers[mBegin + mCapacity] = this;
+        gBuffers[mBegin + mCapacity-1] = this;
     }
 
     __HLAbuffer(void *begin, size_t capacity)
@@ -104,7 +104,7 @@
     {
         __assert_endianess();
         // store "this" to a global table
-        gBuffers[mBegin + mCapacity] = this;
+        gBuffers[mBegin + mCapacity-1] = this;
     }
 
     virtual ~__HLAbuffer()
@@ -122,16 +122,16 @@
 
         mBegin = newBuffer.mBegin;
         mCapacity = newBuffer.mCapacity;
-        gBuffers[mBegin + mCapacity] = this; // update
+        gBuffers[mBegin + mCapacity-1] = this; // update
 
         newBuffer.mBegin = oldBegin;
         newBuffer.mCapacity = oldCapacity;
-        gBuffers[oldBegin + oldCapacity] = &newBuffer; // update
+        gBuffers[oldBegin + oldCapacity-1] = &newBuffer; // update
     }
 
     static BufferList::iterator __buffer_iterator(const void* __this)
     {
-        // find the first pointer not less than "this", what is the end() 
pointer
+        // find the first pointer not less than "this", the last pointer
         BufferList::iterator result = gBuffers.lower_bound((char*)__this);
         if (result == gBuffers.end())
             throw std::runtime_error("HLAdata: bad pointer");
@@ -182,5 +182,5 @@
 
 #endif // _HLATYPES_BUFFER_HH
 
-// $Id: HLAbuffer.hh,v 1.6 2008/11/19 10:25:05 gotthardp Exp $
+// $Id: HLAbuffer.hh,v 1.7 2008/11/22 14:55:58 gotthardp Exp $
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]