more edits
[satune.git] / src / Encoders / elementencoding.c
index 08385db6921096a5bb6b3fcd3c010ae4f3360c7b..47c6ea0fef0f52f917ce7b69e4e09786b3d92e92 100644 (file)
@@ -1,13 +1,17 @@
 #include "elementencoding.h"
+#include "common.h"
+#include "naiveencoder.h"
+#include "element.h"
+#include "satencoder.h"
 
-ElementEncoding * allocElementEncoding(ElementEncodingType type, Element *element) {
-       ElementEncoding * This=ourmalloc(sizeof(ElementEncoding));
+void initElementEncoding(ElementEncoding * This, Element *element) {
        This->element=element;
-       This->type=type;
+       This->type=ELEM_UNASSIGNED;
        This->variables=NULL;
        This->encodingArray=NULL;
+       This->inUseArray=NULL;
        This->numVars=0;
-       return This;
+       This->encArraySize=0;
 }
 
 void deleteElementEncoding(ElementEncoding *This) {
@@ -17,13 +21,20 @@ void deleteElementEncoding(ElementEncoding *This) {
                ourfree(This->encodingArray);
        if (This->inUseArray!=NULL)
                ourfree(This->inUseArray);
-       ourfree(This);
 }
 
 void allocEncodingArrayElement(ElementEncoding *This, uint size) {
        This->encodingArray=ourcalloc(1, sizeof(uint64_t)*size);
+       This->encArraySize=size;
 }
 
 void allocInUseArrayElement(ElementEncoding *This, uint size) {
-       This->inUseArray=ourcalloc(1, size >> 6);
+       uint bytes = ((size + ((1 << 9)-1)) >> 6)&~7;//Depends on size of inUseArray
+       This->inUseArray=ourcalloc(1, bytes);
 }
+
+void setElementEncodingType(ElementEncoding* This, ElementEncodingType type){
+       This->type = type;
+}
+
+