[PATCH] Implement doubly-linked list

Yann E. MORIN yann.morin.1998 at anciens.enib.fr
Wed May 31 22:22:28 UTC 2006


Hello!

Here is at last my implementation of doubly-linked lists.

This is a set of _cumulative_ patches against trunk (rev. 15249) but still
applies to 15252 with one 1-line chunk offset.

Please comment.

001-rename_link_and_functions.patch
 - renames the field "link" of the "llist_t" structure to "next",
 - renames "llist_add_to" to "llist_add_to_front",
 - renames "llist_pop" to "llist_pop_front",
 - update callers/users of /llist_.*/,
 - wrt size, this is a noop, although bloatcheck is not smart enough to see a
   mere function renaming (only a human being can understand that).

002-new_functions.patch
 - adds "llist_pop_end" which returns the "data" of the last element, and
   removes the last element from the list,
 - adds "llist_get_front" and "llist_get_end" which respectively return the
   "data" in the first or last element of the list, and does not touch the
   list,
 - condition free(3)'ing in "llist_pop_front" to "ENABLE_FEATURE_CLEAN_UP",
 - wrt to size, this is a noop as the functions are unused for now. I didn't
   disable "FEATURE_CLEAN_UP" to check the impact on "llist_pop_front" though
   it should be fairly small.

003-doubly_linked_lists.patch
 - adds the configuration option CONFIG_FEATURE_DLLIST:
   - prompt is visible only if building the shared library,
   - defaults to no,
 - conditionnaly adds and set/use the "prev" field to the "llist_t" structure,
 - wrt size:
   - when not enabled, this is a noop,
   - when enabled, here is the result of bloatcheck:

function                                             old     new   delta
llist_add_to_front                                    40      55     +15
llist_add_to_end                                      65      77     +12
llist_pop_front                                       42      50      +8
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 35/0)               Total: 35 bytes

Please note that I'm not happy with the following (that's my code I'm not happy
with!) :
 ---
+       USE_FEATURE_DLLIST (
+               new_head->prev = NULL;
+               if (new_head->next)
+                       new_head->next->prev = new_head;
+       )
 ---

Because if I use "if (ENABLE_FEATURE_DLLIST) " then gcc barfs on the next line.
Comments?

Regards,
Yann E. MORIN.

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +0/33 662376056 | Software  Designer | \ / CAMPAIGN     |   ^                |
| --==< °_° >==-- °---.----------------:  X  AGAINST      |  /e\  There is no  |
| web: ymorin.free.fr | SETI at home 3808 | / \ HTML MAIL    |  """  conspiracy.  |
°---------------------°----------------°------------------°--------------------°
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 001-rename_link_and_functions.patch
Type: text/x-diff
Size: 18447 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/busybox/attachments/20060601/0debec69/attachment.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 002-new_functions.patch
Type: text/x-diff
Size: 2440 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/busybox/attachments/20060601/0debec69/attachment-0001.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 003-doubly_linked_lists.patch
Type: text/x-diff
Size: 3173 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/busybox/attachments/20060601/0debec69/attachment-0002.bin 


More information about the busybox mailing list