diff --git a/packages/cplint/cplint.h b/packages/cplint/cplint.h index dc99bbf82..7aa39e68c 100644 --- a/packages/cplint/cplint.h +++ b/packages/cplint/cplint.h @@ -49,10 +49,6 @@ typedef struct variables createVars(YAP_Term t,DdManager * mgr, int create_dot, char inames[1000][20]); expr createExpression(YAP_Term t); void init_my_predicates(void); -int compare(char *a, char *b); -gint my_equal(gconstpointer v,gconstpointer v2); -guint my_hash(gconstpointer key); -void dealloc(gpointer key,gpointer value,gpointer user_data); diff --git a/packages/cplint/cplint_Prob.c b/packages/cplint/cplint_Prob.c index c1c7967af..a671fcfbe 100644 --- a/packages/cplint/cplint_Prob.c +++ b/packages/cplint/cplint_Prob.c @@ -121,7 +121,7 @@ so that it is not recomputed variable v; double res; double * value_p; - DdNode **key,*nodereg; + DdNode *nodereg; double *rp; index=Cudd_NodeReadIndex(node); @@ -136,7 +136,7 @@ so that it is not recomputed else { nodereg=Cudd_Regular(node); - value_p=g_hash_table_lookup(nodes,&nodereg); + value_p=g_hash_table_lookup(nodes,nodereg); if (value_p!=NULL) { if (comp) @@ -150,11 +150,9 @@ so that it is not recomputed v=vars.varar[mVarIndex]; nBit=v.nBit; res=ProbBool(node,0,nBit,0,v,mVarIndex,vars,nodes,0); - key=(DdNode **)malloc(sizeof(DdNode *)); - *key=nodereg; rp=(double *)malloc(sizeof(double)); *rp=res; - g_hash_table_insert(nodes, key, rp); + g_hash_table_insert(nodes, nodereg, rp); if (comp) return 1-res; else diff --git a/packages/cplint/cplint_yap.c b/packages/cplint/cplint_yap.c index cdc32d58a..87c3b7785 100644 --- a/packages/cplint/cplint_yap.c +++ b/packages/cplint/cplint_yap.c @@ -18,10 +18,8 @@ for the relative license. #include -unsigned long dividend; FILE *open_file (char *filename, const char *mode); -void reverse(char s[]); static int compute_prob(void); variables createVars(YAP_Term t,DdManager * mgr, int create_dot, char inames[1000][20]) @@ -141,7 +139,7 @@ static int compute_prob(void) expr expression; DdNode * function; DdManager * mgr; - int nBVar,i,j,intBits,create_dot; + int nBVar,i,intBits,create_dot; FILE * file; DdNode * array[1]; double prob; @@ -195,18 +193,10 @@ static int compute_prob(void) fclose(file); } - nodes=g_hash_table_new(my_hash,my_equal); + nodes=g_hash_table_new_full(NULL,NULL,NULL,free); intBits=sizeof(unsigned int)*8; - /* dividend is a global variable used by my_hash - it is equal to an unsigned int with binary representation 11..1 */ - dividend=1; - for(j=1;jbval) - return 1; - else - return 0; -} -*/ void init_my_predicates() /* function required by YAP for intitializing the predicates defined by a C function*/ { @@ -257,35 +232,4 @@ open_file(char *filename, const char *mode) return fp; } -void reverse(char s[]) -/* reverses a string */ -{ - int i,c,j; - for (i=0,j=strlen(s)-1;i