All of lore.kernel.org
 help / color / mirror / Atom feed
* Generic list push/pop
@ 2002-08-18 19:21 Daniel Phillips
  2002-08-18 19:28 ` Thunder from the hill
  2002-08-19 12:05 ` William Lee Irwin III
  0 siblings, 2 replies; 8+ messages in thread
From: Daniel Phillips @ 2002-08-18 19:21 UTC (permalink / raw)
  To: linux-kernel

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2002-08-20 15:42 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-08-18 19:21 Generic list push/pop Daniel Phillips
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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.