lkml.org 
[lkml]   [2000]   [Feb]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Improved <linux/lists.h>
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/

\
 
 \ /
  Last update: 2005-03-22 13:56    [W:0.067 / U:0.168 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site