Re: Improved <linux/lists.h>

From: Jeff Garzik (jgarzik@mandrakesoft.com)
Date: Tue Feb 22 2000 - 19:02:53 EST


Borislav Deianov wrote:
> The linux/list.h implementation is a bit weird at first (at least I
> found it so) but is perfectly adequate and very neat once you get used
> to it. Here is your example program rewritten to use linux/list.h
> (modulo insertion/traversal order - easily changeable):

I think it's pretty neat too :)

> ------------------------ <list.c> ------------------------
> #include <stdio.h>
> #include "list.h"
>
> struct node {
> int data;
> struct list_head list;
> };

One technique which is used in the kernel is to, if possible, place the
primary list_head member of a structure at the top of the struct.

This allows you to reference the structure itself as if it were a list,
sometimes saving you a few keystrokes...

-- 
Jeff Garzik              |
Building 1024            | Viva la open source!
MandrakeSoft, Inc.       |

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Wed Feb 23 2000 - 21:00:31 EST