/[svn]/ircd-hybrid/libio/misc/list.c
ViewVC logotype

Diff of /ircd-hybrid/libio/misc/list.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 500 by adx, Wed Oct 5 20:36:04 2005 UTC revision 501 by michael, Thu Mar 2 10:40:42 2006 UTC
# Line 24  Line 24 
24    
25  #include "stdinc.h"  #include "stdinc.h"
26    
27  static BlockHeap *dnode_heap;  static BlockHeap *dnode_heap = NULL;
28    
29  /* init_dlink_nodes()  /* init_dlink_nodes()
30   *   *
# Line 47  init_dlink_nodes(void) Line 47  init_dlink_nodes(void)
47  dlink_node *  dlink_node *
48  make_dlink_node(void)  make_dlink_node(void)
49  {  {
50    dlink_node *lp = BlockHeapAlloc(dnode_heap);    return BlockHeapAlloc(dnode_heap);
   
   return(lp);  
51  }  }
52    
53  /* free_dlink_node()  /* free_dlink_node()
# Line 83  dlinkAdd(void *data, dlink_node *m, dlin Line 81  dlinkAdd(void *data, dlink_node *m, dlin
81      list->tail = m;      list->tail = m;
82    
83    list->head = m;    list->head = m;
84    list->length++;    ++list->length;
85  }  }
86    
87  void  void
# Line 99  dlinkAddBefore(dlink_node *b, void *data Line 97  dlinkAddBefore(dlink_node *b, void *data
97      m->prev = b->prev;      m->prev = b->prev;
98      b->prev = m;      b->prev = m;
99      m->next = b;      m->next = b;
100      list->length++;      ++list->length;
101    }    }
102  }  }
103    
# Line 116  dlinkAddTail(void *data, dlink_node *m, Line 114  dlinkAddTail(void *data, dlink_node *m,
114      list->head = m;      list->head = m;
115    
116    list->tail = m;    list->tail = m;
117    list->length++;    ++list->length;
118  }  }
119    
120  /* Execution profiles show that this function is called the most  /* Execution profiles show that this function is called the most
# Line 143  dlinkDelete(dlink_node *m, dlink_list *l Line 141  dlinkDelete(dlink_node *m, dlink_list *l
141    
142    /* Set this to NULL does matter */    /* Set this to NULL does matter */
143    m->next = m->prev = NULL;    m->next = m->prev = NULL;
144    list->length--;    assert(list->length > 0);
145      --list->length;
146  }  }
147    
148  /*  /*
# Line 159  dlinkFind(dlink_list *list, void *data) Line 158  dlinkFind(dlink_list *list, void *data)
158    dlink_node *ptr;    dlink_node *ptr;
159    
160    DLINK_FOREACH(ptr, list->head)    DLINK_FOREACH(ptr, list->head)
   {  
161      if (ptr->data == data)      if (ptr->data == data)
162        return ptr;        return ptr;
   }  
163    
164    return NULL;    return NULL;
165  }  }
# Line 203  dlinkMoveList(dlink_list *from, dlink_li Line 200  dlinkMoveList(dlink_list *from, dlink_li
200  dlink_node *  dlink_node *
201  dlinkFindDelete(dlink_list *list, void *data)  dlinkFindDelete(dlink_list *list, void *data)
202  {  {
203    dlink_node *m;    dlink_node *m = NULL;
204    
205    DLINK_FOREACH(m, list->head)    DLINK_FOREACH(m, list->head)
206    {    {
207      if (m->data == data)      if (m->data == data)
208      {      {
209        if (m->next)        dlinkDelete(m, list);
         m->next->prev = m->prev;  
       else  
       {  
         assert(list->tail == m);  
         list->tail = m->prev;  
       }  
       if (m->prev)  
         m->prev->next = m->next;  
       else  
       {  
         assert(list->head == m);  
         list->head = m->next;  
       }  
       /* Set this to NULL does matter */  
       m->next = m->prev = NULL;  
       list->length--;  
   
210        return m;        return m;
211      }      }
212    }    }

Legend:
Removed from v.500  
changed lines
  Added in v.501

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.28