Ticket #31312: fix-clause-creator.diff
File fix-clause-creator.diff, 1.6 KB (added by gjasny@…, 12 years ago) |
---|
-
packages/swi-minisat2/C/SolverTypes.h
old new 97 97 //================================================================================================= 98 98 // Clause -- a simple class for representing a clause: 99 99 100 101 100 class Clause { 102 101 uint32_t size_etc; 103 102 union { float act; uint32_t abst; } extra; … … 116 115 size_etc = (ps.size() << 3) | (uint32_t)learnt; 117 116 for (int i = 0; i < ps.size(); i++) data[i] = ps[i]; 118 117 if (learnt) extra.act = 0; else calcAbstraction(); } 119 120 118 // -- use this function instead: 121 template<class V>122 friend Clause* Clause_new(const V& ps, bool learnt = false) {123 assert(sizeof(Lit) == sizeof(uint32_t));124 assert(sizeof(float) == sizeof(uint32_t));125 void* mem = malloc(sizeof(Clause) + sizeof(uint32_t)*(ps.size()));126 return new (mem) Clause(ps, learnt); }127 119 128 120 int size () const { return size_etc >> 3; } 129 121 void shrink (int i) { assert(i <= size()); size_etc = (((size_etc >> 3) - i) << 3) | (size_etc & 7); } … … 146 138 void strengthen (Lit p); 147 139 }; 148 140 141 template<class V> 142 Clause* Clause_new(const V& ps, bool learnt = false) { 143 assert(sizeof(Lit) == sizeof(uint32_t)); 144 assert(sizeof(float) == sizeof(uint32_t)); 145 void* mem = malloc(sizeof(Clause) + sizeof(uint32_t)*(ps.size())); 146 return new (mem) Clause(ps, learnt); 147 } 148 149 149 150 150 /*_________________________________________________________________________________________________ 151 151 |