more edits
[satune.git] / src / Encoders / elementencoding.c
index 095f99ded848dc8dc3d4316b951a0eef971de42e..47c6ea0fef0f52f917ce7b69e4e09786b3d92e92 100644 (file)
@@ -1,19 +1,40 @@
 #include "elementencoding.h"
+#include "common.h"
+#include "naiveencoder.h"
+#include "element.h"
+#include "satencoder.h"
 
-ElementEncoding * allocElementEncoding(ElementEncodingType type, Element *element) {
-       ElementEncoding * this=(ElementEncoding *)ourmalloc(sizeof(ElementEncoding));
-       this->element=element;
-       this->type=type;
-       this->variables=NULL;
-       this->encodingArray=NULL;
-       this->numVars=0;
-       return this;
+void initElementEncoding(ElementEncoding * This, Element *element) {
+       This->element=element;
+       This->type=ELEM_UNASSIGNED;
+       This->variables=NULL;
+       This->encodingArray=NULL;
+       This->inUseArray=NULL;
+       This->numVars=0;
+       This->encArraySize=0;
 }
 
-void deleteElementEncoding(ElementEncoding *this) {
-       if (this->variables!=NULL)
-               ourfree(this->variables);
-       if (this->encodingArray!=NULL)
-               ourfree(this->encodingArray);
-       ourfree(this);
+void deleteElementEncoding(ElementEncoding *This) {
+       if (This->variables!=NULL)
+               ourfree(This->variables);
+       if (This->encodingArray!=NULL)
+               ourfree(This->encodingArray);
+       if (This->inUseArray!=NULL)
+               ourfree(This->inUseArray);
 }
+
+void allocEncodingArrayElement(ElementEncoding *This, uint size) {
+       This->encodingArray=ourcalloc(1, sizeof(uint64_t)*size);
+       This->encArraySize=size;
+}
+
+void allocInUseArrayElement(ElementEncoding *This, uint size) {
+       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;
+}
+
+