Fix memory errors detected by valgrind and inline functions
authorbdemsky <bdemsky@uci.edu>
Thu, 22 Jun 2017 19:56:09 +0000 (12:56 -0700)
committerbdemsky <bdemsky@uci.edu>
Thu, 22 Jun 2017 19:56:09 +0000 (12:56 -0700)
.gitignore
src/Backend/constraint.h
src/Collections/vector.h
src/Encoders/elementencoding.c
src/Encoders/elementencoding.h

index 39d4e58..c6f1f57 100644 (file)
@@ -5,3 +5,5 @@ nbproject/
 src/bin/
 src/lib_cons_comp.so
 /src/mymemory.cc
+.*
+*.dSYM
\ No newline at end of file
index d6e7e86..a83a39b 100644 (file)
@@ -33,15 +33,15 @@ Constraint * allocVarConstraint(CType t, uint var);
 void deleteConstraint(Constraint *);
 void printConstraint(Constraint * c);
 void dumpConstraint(Constraint * c, IncrementalSolver *solver);
-inline uint getVarConstraint(Constraint * c) {ASSERT(c->type==VAR); return c->numoperandsorvar;}
+static inline uint getVarConstraint(Constraint * c) {ASSERT(c->type==VAR); return c->numoperandsorvar;}
 VectorConstraint * simplify(Constraint * c);
-inline CType getType(Constraint * c) {return c->type;}
-inline bool isFalse(Constraint * c) {return c->type==FALSE;}
-inline bool isTrue(Constraint * c) {return c->type==TRUE;}
+static inline CType getType(Constraint * c) {return c->type;}
+static inline bool isFalse(Constraint * c) {return c->type==FALSE;}
+static inline bool isTrue(Constraint * c) {return c->type==TRUE;}
 void internalfreeConstraint(Constraint * c);
 void freerecConstraint(Constraint * c);
 Constraint * cloneConstraint(Constraint * c);
-inline void setNegConstraint(Constraint * This, Constraint *c) {This->neg=c;}
+static inline void setNegConstraint(Constraint * This, Constraint *c) {This->neg=c;}
 Constraint *negateConstraint(Constraint * c);
 
 extern Constraint ctrue;
index 72e504f..76da387 100644 (file)
@@ -29,7 +29,7 @@
                return allocVector ## name(defcap);                                 \
        }                                                                     \
        Vector ## name * allocVector ## name(uint capacity) {                 \
-               Vector ## name * tmp = (Vector ## name *)ourmalloc(sizeof(type));  \
+               Vector ## name * tmp = (Vector ## name *)ourmalloc(sizeof(Vector ## name));  \
                tmp->size = 0;                                                      \
                tmp->capacity = capacity;                                           \
                tmp->array = (type *) ourcalloc(1, sizeof(type) * capacity);          \
index ecabd1b..217327d 100644 (file)
@@ -5,6 +5,7 @@ void initElementEncoding(ElementEncoding * This, Element *element) {
        This->type=ELEM_UNASSIGNED;
        This->variables=NULL;
        This->encodingArray=NULL;
+       This->inUseArray=NULL;
        This->numVars=0;
 }
 
index 3ade03b..1af74be 100644 (file)
@@ -23,11 +23,11 @@ void baseBinaryIndexElementAssign(ElementEncoding *This);
 void allocEncodingArrayElement(ElementEncoding *This, uint size);
 void allocInUseArrayElement(ElementEncoding *This, uint size);
 
-inline bool isinUseElement(ElementEncoding *This, uint offset) {
+static inline bool isinUseElement(ElementEncoding *This, uint offset) {
        return (This->inUseArray[(offset>>6)] >> (offset & 63)) &0x1;
 }
 
-inline void setInUseElement(ElementEncoding *This, uint offset) {
+static inline void setInUseElement(ElementEncoding *This, uint offset) {
        This->inUseArray[(offset>>6)] |= 1 << (offset & 63);
 }
 #endif