LIFO in C, need your suggestions

G

Giorgos Keramidas

| There are nice macros for singly-linked lists, doubly-linked lists and
| tail-queues in BSD and Linux. A tail-queue can serve as a very nice
| LIFO if you wrap it in code of your own to insert elements at the head
| and remove them from the tail (or vice versa).
|
| Have a look at /usr/include/sys/queue.h in FreeBSD and Linux.
|
| It's often a good idea to *avoid* reimplementing a particular wheel,
| especially if there is a possibility for amusing ``corners'' (bugs,
| limitations, or lack of features) in the new wheel reimplementation :)

OTOH, it can be good to reimplement when the new one fixes bugs in the
legacy implementation.

Heh, good point :)
The queue.h implementation does not protect against multiple
evaluation of arguments. I have code that does. The tradeoff is that
my code is not as widely tested (that's what you get with any new
code). In fact, these are not even officially released. So of course
I'd like to see it tested more widely. You can preview (and even use)
them here.

The linked list macro collection by itself:
http://phil.ipal.org/pre-release/list-0.0.6/list.h

The linked list macro collection in a larger collection:
http://phil.ipal.org/pre-release/dropinc-0.0.0/misc/list.i

These are now licensed under the BSD-like license used by OpenBSD.

Excellent! I'll have a look and thank you for releasing the code under
a BSD-friendly license.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top