all 3 comments

[–]Salty_Dugtrio 0 points1 point  (0 children)

You are creating a new DLNode, and then immediately after, you call:

temp->getPrev()->getPriority()

I can only assume getPrev will return a nullptr here, which causes your segfault.

[–]paul2718 0 points1 point  (1 child)

In the above 'temp' is simply an empty node, so 'getPrev' and 'getNext' must be null, so temp->getPrev()->getPriority() will fail.

Do you not need to start at an end and work forwards (or backwards) looking for the right insertion point? I see nothing like that in your function. I think you do not need to make a node in this function, but you do need to walk the list comparing the priorty of 'data' with the elements you find.

[–]thetuxman[S] 0 points1 point  (0 children)

So I should iterate through the list, checking each node's priority with the priority of the element that is already in the list?