Skip to content

Commit

Permalink
Old pointers of sibling were not cleared
Browse files Browse the repository at this point in the history
When adding sibling at the head of linked list, the head if pointing
to something in linked list was not updated, hence a loop was formed
in linked list

Element0 - First addition to linked list
Element1 - Has higher delay hence added to back
0 ->(next) 1
Element2 - Delay is same as Element0, hence should be sibling of 0
           Shall be added at head

Expected:
2    ------------->(next) 1
|(sibling)
0

Bug: (Resolved with this)
2    ------------->(next) 1
|(sibling)
0    ------------->(next) 1

If we add more elements and next pointer of sibling is updated, old
references will cause issues
Element3 added

Expected:
2    ------------->(next) 3  ------------->(next) 1
|(sibling)
0

Bug: (Resolved with this)
2    ------------->(next) 3  ------------->(next) 1
|(sibling)
0    ------------->(next) 1
***Both siblings here point to different next***
  • Loading branch information
deepikabhavnani authored and geky committed Aug 4, 2019
1 parent dc80add commit 023a1d9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion equeue.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ static int equeue_enqueue(equeue_t *q, struct equeue_event *e, unsigned tick) {
if (e->next) {
e->next->ref = &e->next;
}

e->sibling = *p;
e->sibling->next = 0;
e->sibling->ref = &e->sibling;
} else {
e->next = *p;
Expand Down

0 comments on commit 023a1d9

Please sign in to comment.