Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#7105 closed enhancement (implemented)

Use queue.h as our linked list implementation

Reported by: nickm Owned by:
Priority: Medium Milestone: Tor: 0.2.4.x-final
Component: Core Tor/Tor Version:
Severity: Keywords: tor-relay refactoring
Cc: andrea Actual Points:
Parent ID: Points:
Reviewer: Sponsor:

Description

Linked lists can be tricky. Doubly linked lists, doubly so. Even more so if you're trying to do the right magic to avoid needless dereferences (e.g., storing prev as a pointer-to-pointer).

So let's use a well-defined abstraction. Since the BSD days, many operating systems have had a sys/queue.h that defines singly- and doubly-linked lists and queues. Let's grab the one from OpenBSD (see commit for explanation why) and use that.

I don't think we should do an all-at-once conversion for all our linked lists, but converting them as the opportunity appears would be a good thing.

Child Tickets

Change History (5)

comment:1 Changed 7 years ago by nickm

Cc: andrea added
Status: newneeds_review

See branch "bsd_queue" in my public repository. It changes a couple of instances in channel.c, since that's new and fresh in my mind. Do you like it?

comment:2 Changed 7 years ago by rransom

It might be useful to include the queue(3) man page in src/ext/ too, for people who need to hack on Tor offline and don't have OpenBSD sources handy.

comment:3 Changed 7 years ago by andrea

This code all looks okay to me; I'm giving it a test run now.

comment:4 Changed 7 years ago by andrea

Resolution: implemented
Status: needs_reviewclosed

Test run looks fine; I'll go ahead and merge.

comment:5 Changed 7 years ago by nickm

Thanks; I've also added a copy of the manpage at rransom's suggestion.

Note: See TracTickets for help on using tickets.