Fixing memory buggit status
[satune.git] / src / Encoders / elementencoding.cc
index 19439dc426e88933e13a4561d878398316611cc8..02d4898e3515959b969e869494ff2f4d23a27aa8 100644 (file)
@@ -13,7 +13,10 @@ ElementEncoding::ElementEncoding(Element *_element) :
        variables(NULL),
        encodingArray(NULL),
        inUseArray(NULL),
+       edgeArray(NULL),
+       polarityArray(NULL),
        encArraySize(0),
+       encoding(EENC_UNKNOWN),
        numVars(0) {
 }
 
@@ -24,6 +27,10 @@ ElementEncoding::~ElementEncoding() {
                ourfree(encodingArray);
        if (inUseArray != NULL)
                ourfree(inUseArray);
+       if (edgeArray != NULL)
+               ourfree(edgeArray);
+       if (polarityArray != NULL)
+               ourfree(polarityArray);
 }
 
 void ElementEncoding::allocEncodingArrayElement(uint size) {
@@ -32,7 +39,7 @@ void ElementEncoding::allocEncodingArrayElement(uint size) {
 }
 
 void ElementEncoding::allocInUseArrayElement(uint size) {
-       uint bytes = ((size + ((1 << 9) - 1)) >> 6) & ~7;//Depends on size of inUseArray
+       uint bytes = ((size + 63) >> 3) & ~7;   //Depends on size of inUseArray
        inUseArray = (uint64_t *) ourcalloc(1, bytes);
 }
 
@@ -47,7 +54,7 @@ void ElementEncoding::encodingArrayInitialization() {
        allocEncodingArrayElement(encSize);
        allocInUseArrayElement(encSize);
        for (uint i = 0; i < size; i++) {
-               encodingArray[i] = set->getMemberAt(i);
+               encodingArray[i] = set->getElement(i);
                setInUseElement(i);
        }
 }