[lkml]   [2008]   [Mar]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: [PATCH] Corrections to Documentation/rbtree.txt
    On 20/03/08 18:39, Rob Landley wrote:
    > On Thursday 20 March 2008 10:29:57 Ian Abbott wrote:
    >> From: Ian Abbott <>
    >> The description of the rb_entry() macro in Documentation/rbtree.txt seems
    >> incorrect. This patch improves it (hopefully). Also I changed the example
    >> code to call the previous 'my_search()' example instead of an undefined
    >> 'mysearch()'.
    > I have no objection to the patch (and the my_search thing seems like an
    > obvious typo), but is there a reason to prefer rb_entry() rather than
    > container_of()? If so, the rationale might be a good thing to add to the
    > documentation...

    I don't know the rationale, but all the code I can see uses rb_entry()
    and not container_of(). The only rationale I can think of is that it
    abstracts away from the nodes being embedded in the data a little bit.
    (But not by much - in particular, an implementation of rb trees that
    stored data in the node explicitly would only need a single parameter in
    its rb_entry() accessor. I like the approach taken in
    include/linux/elevator.h that uses the rb_entry() macro to create a
    specialized accessor macro (rb_entry_rq()) with a single parameter.

    -=( Ian Abbott @ MEV Ltd. E-mail: <> )=-
    -=( Tel: +44 (0)161 477 1898 FAX: +44 (0)161 718 3587 )=-

     \ /
      Last update: 2008-03-25 12:05    [W:0.022 / U:13.596 seconds]
    ©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site