Skip to content

Commit c932abe

Browse files
committed
Fixed wrong allocation size of malloc
1 parent e90ce8a commit c932abe

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

core.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,14 @@ void _c3_print_cnf (C3List *cnf) {
7171
int32_t *num;
7272
c3_list_foreach (cnf, iter, disj) {
7373
printf ("(");
74+
//printf ("[%p] ", iter);
7475
c3_list_foreach (disj, iter2, num) {
7576
if (*num < 0) {
7677
printf ("!x%d", -(*num));
78+
//printf ("!x%d(%p)", -(*num), num);
7779
} else {
7880
printf ("x%d", *num);
81+
//printf ("x%d(%p)", *num, num);
7982
}
8083
if (iter2 != disj->tail) { //XXX
8184
printf (" or ");
@@ -305,9 +308,9 @@ static bool _c3_dpll_simplify2(C3 *c3, C3List *cnf, int32_t *res) {
305308
continue;
306309
}
307310
absi = abs(i);
308-
printf ("pure literal %d\n", i);
309311
res[absi - 1] = (i < 0) ? -1 : 1;
310312
iter = cnf->head;
313+
//printf ("pure literal %d\t%p\n", i, iter);
311314
while (iter) {
312315
disj = iter->data;
313316
next = iter->n;
@@ -318,6 +321,7 @@ static bool _c3_dpll_simplify2(C3 *c3, C3List *cnf, int32_t *res) {
318321
iter = next;
319322
}
320323
updated = true;
324+
_c3_print_cnf (cnf);
321325
}
322326
c3_hmap_clear (c3->literals);
323327
return updated;
@@ -512,7 +516,7 @@ int main(int argc, char **argv, char **envp) {
512516
}
513517
c3_print_cnf (&c3);
514518
c3_sort_cnf (&c3);
515-
res = (int8_t*) calloc (c3.valnum, sizeof(int8_t));
519+
res = (int8_t*) calloc (c3.valnum, sizeof(int32_t));
516520
status = c3_derive_sat (&c3, res);
517521
//c3_print_cnf (&c3);
518522
printf ("s %s\n", status_str[status]);

list.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ void c3_listiter_delete(C3List *list, C3ListIter *iter) {
6969
if (iter->n) {
7070
iter->n->p = iter->p;
7171
}
72-
c3_listiter_free (iter);
72+
//c3_listiter_free (iter);
7373
list->length--;
7474
}
7575
}
@@ -90,7 +90,7 @@ void c3_listiter_free(C3ListIter *iter) {
9090
free (iter->data);
9191
}
9292
/* XXX: this free cause 'free(): invalid next size (fast) error' */
93-
//free (iter);
93+
free (iter);
9494
}
9595
}
9696

0 commit comments

Comments
 (0)