The destroy function leaks the memory of the nodes. You need to loop over the queue and free each node one by one.