projects
/
satune.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
qsort has a malloc hidden inside of it...It breaks our library when used with satcheck
[satune.git]
/
src
/
csolver.cc
diff --git
a/src/csolver.cc
b/src/csolver.cc
index ea16b8043ca84619cd2804d24f43c007f0bedcac..62f76ab2223065363a8fcbdcfccdba0cb2e5b862 100644
(file)
--- a/
src/csolver.cc
+++ b/
src/csolver.cc
@@
-17,7
+17,7
@@
#include "structs.h"
#include "orderresolver.h"
#include "integerencoding.h"
#include "structs.h"
#include "orderresolver.h"
#include "integerencoding.h"
-#include
<stdlib.h>
+#include
"qsort.h"
CSolver::CSolver() :
boolTrue(BooleanEdge(new BooleanConst(true))),
CSolver::CSolver() :
boolTrue(BooleanEdge(new BooleanConst(true))),
@@
-77,7
+77,7
@@
CSolver *CSolver::clone() {
SetIteratorBooleanEdge *it = getConstraints();
while (it->hasNext()) {
BooleanEdge b = it->next();
SetIteratorBooleanEdge *it = getConstraints();
while (it->hasNext()) {
BooleanEdge b = it->next();
- copy->addConstraint(
b->clone(copy, &map
));
+ copy->addConstraint(
cloneEdge(copy, &map, b
));
}
delete it;
return copy;
}
delete it;
return copy;
@@
-143,6
+143,7
@@
Element *CSolver::applyFunction(Function *function, Element **array, uint numArr
Element *element = new ElementFunction(function,array,numArrays,overflowstatus);
Element *e = elemMap.get(element);
if (e == NULL) {
Element *element = new ElementFunction(function,array,numArrays,overflowstatus);
Element *e = elemMap.get(element);
if (e == NULL) {
+ element->updateParents();
allElements.push(element);
elemMap.put(element, element);
return element;
allElements.push(element);
elemMap.put(element, element);
return element;
@@
-212,6
+213,7
@@
BooleanEdge CSolver::applyPredicateTable(Predicate *predicate, Element **inputs,
BooleanPredicate *boolean = new BooleanPredicate(predicate, inputs, numInputs, undefinedStatus);
Boolean *b = boolMap.get(boolean);
if (b == NULL) {
BooleanPredicate *boolean = new BooleanPredicate(predicate, inputs, numInputs, undefinedStatus);
Boolean *b = boolMap.get(boolean);
if (b == NULL) {
+ boolean->updateParents();
boolMap.put(boolean, boolean);
allBooleans.push(boolean);
return BooleanEdge(boolean);
boolMap.put(boolean, boolean);
allBooleans.push(boolean);
return BooleanEdge(boolean);
@@
-316,7
+318,7
@@
BooleanEdge CSolver::applyLogicalOperation(LogicOp op, BooleanEdge *array, uint
} else if (newindex == 1) {
return newarray[0];
} else {
} else if (newindex == 1) {
return newarray[0];
} else {
- qsort(newarray, newindex, sizeof(BooleanEdge), ptrcompares);
+
bsd
qsort(newarray, newindex, sizeof(BooleanEdge), ptrcompares);
array = newarray;
asize = newindex;
}
array = newarray;
asize = newindex;
}
@@
-336,6
+338,7
@@
BooleanEdge CSolver::applyLogicalOperation(LogicOp op, BooleanEdge *array, uint
Boolean *boolean = new BooleanLogic(this, op, array, asize);
Boolean *b = boolMap.get(boolean);
if (b == NULL) {
Boolean *boolean = new BooleanLogic(this, op, array, asize);
Boolean *b = boolMap.get(boolean);
if (b == NULL) {
+ boolean->updateParents();
boolMap.put(boolean, boolean);
allBooleans.push(boolean);
return BooleanEdge(boolean);
boolMap.put(boolean, boolean);
allBooleans.push(boolean);
return BooleanEdge(boolean);
@@
-374,10
+377,6
@@
void CSolver::addConstraint(BooleanEdge constraint) {
}
constraints.add(constraint);
Boolean *ptr=constraint.getBoolean();
}
constraints.add(constraint);
Boolean *ptr=constraint.getBoolean();
- if (constraint.isNegated())
- updateMustValue(ptr, BV_MUSTBEFALSE);
- else
- updateMustValue(ptr, BV_MUSTBETRUE);
if (ptr->boolVal == BV_UNSAT)
setUnSAT();
if (ptr->boolVal == BV_UNSAT)
setUnSAT();
@@
-407,9
+406,8
@@
int CSolver::solve() {
DecomposeOrderTransform dot(this);
dot.doTransform();
DecomposeOrderTransform dot(this);
dot.doTransform();
- //This leaks like crazy
- // IntegerEncodingTransform iet(this);
- //iet.doTransform();
+ IntegerEncodingTransform iet(this);
+ iet.doTransform();
naiveEncodingDecision(this);
satEncoder->encodeAllSATEncoder(this);
naiveEncodingDecision(this);
satEncoder->encodeAllSATEncoder(this);