Skip to content

Commit 252c7a0

Browse files
kernel: fix issues with assumptions in IS_ACYCLIC_DIGRAPH
1 parent 423ceee commit 252c7a0

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

src/digraphs.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -405,14 +405,14 @@ static Obj FuncIS_ACYCLIC_DIGRAPH(Obj self, Obj adj) {
405405
Obj nbs;
406406
UInt *stack, *ptr;
407407

408-
nr = LEN_PLIST(adj);
408+
nr = LEN_LIST(adj);
409409

410410
// init the buf
411411
ptr = safe_calloc(nr + 1, sizeof(UInt));
412412
stack = safe_malloc((2 * nr + 2) * sizeof(UInt));
413413

414414
for (i = 1; i <= nr; i++) {
415-
nbs = ELM_PLIST(adj, i);
415+
nbs = ELM_LIST(adj, i);
416416
if (LEN_LIST(nbs) == 0) {
417417
ptr[i] = 1;
418418
} else if (ptr[i] == 0) {
@@ -431,7 +431,7 @@ static Obj FuncIS_ACYCLIC_DIGRAPH(Obj self, Obj adj) {
431431
// Check whether:
432432
// 1. We've previously finished with this vertex, OR
433433
// 2. Whether we've now investigated all descendant branches
434-
nbs = ELM_PLIST(adj, j);
434+
nbs = ELM_LIST(adj, j);
435435
if (ptr[j] == 1 || k > (UInt) LEN_LIST(nbs)) {
436436
ptr[j] = 1;
437437
level--;
@@ -445,9 +445,9 @@ static Obj FuncIS_ACYCLIC_DIGRAPH(Obj self, Obj adj) {
445445
} else { // Otherwise move onto the next available branch
446446
ptr[j] = 2;
447447
level++;
448-
nbs = ELM_PLIST(adj, j);
448+
nbs = ELM_LIST(adj, j);
449449
stack += 2;
450-
stack[0] = INT_INTOBJ(CONST_ADDR_OBJ(nbs)[k]);
450+
stack[0] = INT_INTOBJ(ELM_LIST(nbs, k));
451451
stack[1] = 1;
452452
}
453453
}
@@ -1359,10 +1359,10 @@ static Obj FuncDIGRAPH_REFLEX_TRANS_CLOSURE(Obj self, Obj digraph) {
13591359
}
13601360

13611361
static Obj FuncRANDOM_DIGRAPH(Obj self, Obj nn, Obj pp) {
1362-
UInt n, i, j;
1363-
Double p, q;
1364-
Int len;
1365-
Obj adj, adji;
1362+
UInt n, i, j;
1363+
Double p, q;
1364+
Int len;
1365+
Obj adj, adji;
13661366

13671367
n = INT_INTOBJ(nn);
13681368
p = VAL_MACFLOAT(pp);

0 commit comments

Comments
 (0)