DLIST changes
Sam Liddicott
sam at liddicott.com
Fri Jan 21 03:39:04 MST 2011
In re-basing my work on alpha15 I'm bitten by some dlist changes.
I've worked round them, but suggest some changes to DLIST.
I suggest a change (1) and an additional choice of changes (2).
For my own code I shall adopt (1) and (2.2) for the time being.
1. addition of DLIST_ADD_END with 2 parameters.
It is fine that the third parameter is ignored, but we can at least
avoid requiring it to be specified for new code.
2. support of void* list-heads.
I make use of void* private pointers, like
smbcli_request.asyc.private_data as list heads.
As more dlist macros do things like both of these internally:
a. (list)->prev
b. (list)=(p)->next
the list argument to the macros can't include a typecast. This was true
in some cases but now is true in more cases.
So I propose EITHER:
2.1 additional 3-parameter variants which actually use the third
parameter - like this:
#define DLIST_ADD(list, p, type) \
do { \
type *list_typed=&(list); \
DLIST_ADD(*list_typed, p); \
} \
while(0);
OR
2.2 a DLIST_TYPE to be invocable as a filthy outer-macro like this:
#define DLIST_TYPE(list, type, DLIST_STATEMENT) do { \
type *THELIST=&(list); \
DLIST_STATEMENT; \
} while(0)
and so void* list heads might be used with nested macros like this; the
actual list and type being specified in the outer-macro and *THELIST
being used as the first parameter in the inner macro:
DLIST_TYPE(creq->async.private_data, struct async_info_map *,
DLIST_ADD_END(*THELIST, async));
I am happy to write the code if someone in authority will give an idea
of what approach (if any) would be acceptable.
Sam
More information about the samba-technical
mailing list