[PATCH 1/4] Add null-terminated list interface.

Peter Hutterer peter.hutterer at who-t.net
Thu Aug 11 04:02:30 PDT 2011


On 11/08/11 20:52 , walter harms wrote:
>
>
> Am 11.08.2011 05:20, schrieb Peter Hutterer:
>> This is a set of macros to provide a struct list-alike interface for classic
>> linked lists such as the XF86OptionRec or the DeviceIntRec. The typical
>> format for these is to have a "struct foo *next" pointer in each struct foo
>> and walk through those. These macros provide a few basic functions to add to,
>> remove from and iterate through these lists.
>>
>> While struct list is in some ways more flexible, switching legacy code to
>> use struct list is not alway viable. These macros at least reduce the amount
>> of open-coded lists.
>>
>
> hello,
>
> did you take a look at "man queue" ? glibc and BSD* provide a sys/queue.h
> that has a set of macro to support linked lists.

Hmm, completely forgot about that one. As you probably saw in the 
follow-up patches the main reason for these macros is to have a drop-in 
replacement to re-use the XF86OptionRec struct without having to touch 
that code. I tried switching that code to struct list but it's virtually 
untestable, there are be too many exceptions, corner cases and hard to 
hit or find code paths that we won't find out for ages.

AFAICT from a quick read, queue.h requires a list head for any list 
handling. Which would have the same issues as the struct list approach - 
all the xfree86 option code would need subtle changes and testing.

Cheers,
   PEter


More information about the xorg-devel mailing list