]> git.unchartedbackwaters.co.uk Git - francis/stp.git/commitdiff
CMS2 update missed out on the MTL library changes. Fixed.
authormsoos <msoos@e59a4935-1847-0410-ae03-e826735625c1>
Mon, 19 Apr 2010 06:26:40 +0000 (06:26 +0000)
committermsoos <msoos@e59a4935-1847-0410-ae03-e826735625c1>
Mon, 19 Apr 2010 06:26:40 +0000 (06:26 +0000)
git-svn-id: https://stp-fast-prover.svn.sourceforge.net/svnroot/stp-fast-prover/trunk/stp@691 e59a4935-1847-0410-ae03-e826735625c1

src/sat/cryptominisat2/mtl/Heap.h
src/sat/cryptominisat2/mtl/Vec.h

index 24d2df19925db55fc3a225919bf8e6a517d552bf..a2ae468fa407f1e27a0baf639c27e0f7c9b09c17 100644 (file)
@@ -21,6 +21,7 @@ OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWA
 #define Heap_h
 
 #include "Vec.h"
+#include <algorithm>
 
 #include "string.h"
 #include <limits>
@@ -87,9 +88,9 @@ class Heap {
     Heap(const Comp& c) : lt(c) { }
     Heap(const Heap<Comp>& other) : lt(other.lt) {
         heap.growTo(other.heap.size());
-        memcpy(heap.getData(), other.heap.getData(), sizeof(uint32_t)*other.heap.size());
+        std::copy(other.heap.getData(), other.heap.getDataEnd(), heap.getData());
         indices.growTo(other.indices.size());
-        memcpy(indices.getData(), other.indices.getData(), sizeof(uint32_t)*other.indices.size());
+        std::copy(other.indices.getData(), other.indices.getDataEnd(), indices.getData());
     }
     
     void operator=(const Heap<Comp>& other)
@@ -97,14 +98,14 @@ class Heap {
         if (other.heap.size() > heap.size())
             heap.growTo(other.heap.size());
         else
-            heap.shrink(other.heap.size()-heap.size());
-        memcpy(heap.getData(), other.heap.getData(), heap.size()*sizeof(uint32_t));
+            heap.shrink(heap.size()-other.heap.size());
+        std::copy(other.heap.getData(), other.heap.getDataEnd(), heap.getData());
         
         if (other.indices.size() > indices.size())
             indices.growTo(other.indices.size());
         else
-            indices.shrink(other.indices.size()-indices.size());
-        memcpy(indices.getData(), other.indices.getData(), indices.size()*sizeof(uint32_t));
+            indices.shrink(indices.size() - other.indices.size());
+        std::copy(other.indices.getData(), other.indices.getDataEnd(), indices.getData());
     }
 
     uint32_t  size      ()          const { return heap.size(); }
index 560f0a139645dcc4fcc3f0613babee8848d81ebf..1c6c1aedaf229e91cd3cecfbfbd404c52bedabf5 100644 (file)
@@ -88,7 +88,7 @@ public:
     void     capacity (uint32_t size) { grow(size); }
 
     // Stack interface:
-    void     reserve(uint32_t res)     { grow(res);}
+    void     reserve(uint32_t res)     { if (cap < res) {cap = res; data = (T*)realloc(data, cap * sizeof(T));}}
     void     push  (void)              { if (sz == cap) { cap = imax(2, (cap*3+1)>>1); data = (T*)realloc(data, cap * sizeof(T)); } new (&data[sz]) T(); sz++; }
     void     push  (const T& elem)     { if (sz == cap) { cap = imax(2, (cap*3+1)>>1); data = (T*)realloc(data, cap * sizeof(T)); } data[sz++] = elem; }
     void     push_ (const T& elem)     { assert(sz < cap); data[sz++] = elem; }