Ignore:
Timestamp:
Dec 22, 2008, 7:16:06 PM (13 years ago)
Author:
charles
Message:

(trunk libT) speed improvments from wereHamster

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/list.h

    r7467 r7469  
    5353                       TrListCompareFunc compare_func );
    5454
     55
     56/*
     57 * Double-linked list with easy memory management and fast
     58 * insert/remove operations
     59 */
     60
     61struct __tr_list
     62{
     63    struct __tr_list * next, * prev;
     64};
     65
     66#define __tr_list_entry(ptr, type, member) ({            \
     67    const struct __tr_list *__mptr = (ptr);              \
     68    (void *)( (char *)__mptr - offsetof(type,member) );  \
     69})
     70
     71typedef int  ( *__tr_list_cmp_t ) ( const void * a, const void * b );
     72typedef void ( *__tr_list_free_t )( void * );
     73
     74
     75/**
     76 *    __tr_list_init()
     77 *
     78 * Init @head as an empty list.
     79 */
     80void
     81__tr_list_init( struct __tr_list * head );
     82
     83
     84/**
     85 *    __tr_list_insert()
     86 *
     87 * Insert @list between @prev and @next.
     88 */
     89void
     90__tr_list_insert( struct __tr_list * list,
     91                  struct __tr_list * prev,
     92                  struct __tr_list * next);
     93
     94/**
     95 *    __tr_list_splice()
     96 *
     97 * Connect @prev with @next, removing any nodes that were
     98 * in between.
     99 */
     100void
     101__tr_list_splice( struct __tr_list * prev,
     102                  struct __tr_list * next);
     103
     104/**
     105 *    __tr_list_append()
     106 *
     107 * Append @list to the end of @head.
     108 */
     109void
     110__tr_list_append( struct __tr_list * head,
     111                  struct __tr_list * list);
     112
     113/**
     114 *    __tr_list_remove()
     115 *
     116 * Remove @head from the list it is in.
     117 */
     118void
     119__tr_list_remove( struct __tr_list * head );
     120
     121/**
     122 *    __tr_list_destroy()
     123 *
     124 * Destroy the list and free all nodes
     125 */
     126void
     127__tr_list_destroy( struct __tr_list * head,
     128                   __tr_list_free_t   func);
     129
    55130#endif /* TR_LIST_H */
    56131
Note: See TracChangeset for help on using the changeset viewer.