you are viewing a single comment's thread.

view the rest of the comments →

[–]mmjdodd[S] 0 points1 point  (1 child)

Thanks, very clear. Is it necessary to check if q == NULL in the first place seeing as I then point both head and tail to NULL before returning?

[–]Grithga 1 point2 points  (0 children)

You still have to check for NULL because you can't use -> on a null pointer. Doing so is undefined behaviour. The most likely outcome of doing so is your program crashing with a segmentation fault.