From: Daniel Phillips <phillips@arcor.de>
To: linux-kernel@vger.kernel.org
Subject: Generic list push/pop
Date: Sun, 18 Aug 2002 21:21:41 +0200 [thread overview]
Message-ID: <E17gVcL-00031m-00@starship> (raw)
I took a run at writing generic single-linked list push and pop macros, to be
used in the form:
push_list(foo_list, foo_node);
and
foo_node = pop_list(foo_list);
They came out predictably ugly:
#define push_list(_LIST_, _NODE_) \
_NODE_->next = _LIST_; \
_LIST_ =_NODE_;
#define pop_list(_LIST_) ({ \
typeof(_LIST_) _NODE_ = _LIST_; \
_LIST_ = _LIST_->next; \
_NODE_; })
These work but imho, they are too ugly to live. For one thing, they assume
the link field is named 'next' and I don't see a nice way around that.
Before moving them to my scraps.c file I thought I'd let other people throw
some tomatoes at them.
--
Daniel
next reply other threads:[~2002-08-18 19:15 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-08-18 19:21 Daniel Phillips [this message]
2002-08-18 19:28 ` Thunder from the hill
2002-08-18 20:34 ` Daniel Phillips
2002-08-19 12:05 ` William Lee Irwin III
2002-08-19 12:32 ` Daniel Phillips
2002-08-20 13:08 ` Thunder from the hill
2002-08-20 15:30 ` Daniel Phillips
2002-08-20 15:45 ` Thunder from the hill
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E17gVcL-00031m-00@starship \
--to=phillips@arcor.de \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®