/[svn]/hopm/branches/1.1.x/src/list.c
ViewVC logotype

Diff of /hopm/branches/1.1.x/src/list.c

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

revision 8580 by michael, Sun Oct 14 15:15:05 2018 UTC revision 8581 by michael, Sun Oct 14 16:58:58 2018 UTC
# Line 31  Line 31 
31    
32    
33  node_t *  node_t *
34  node_create(void *data)  node_create(void)
35  {  {
36    node_t *node = xcalloc(sizeof *node);    node_t *node = xcalloc(sizeof *node);
   
   node->data = data;  
   
37    return node;    return node;
38  }  }
39    
40    void
41    node_free(node_t *node)
42    {
43      xfree(node);
44    }
45    
46  node_t *  node_t *
47  list_add(list_t *list, node_t *node)  list_add(void *data, node_t *node, list_t *list)
48  {  {
49      node->data = data;
50    node->prev = NULL;    node->prev = NULL;
51    node->next = list->head;    node->next = list->head;
52    
# Line 59  list_add(list_t *list, node_t *node) Line 63  list_add(list_t *list, node_t *node)
63  }  }
64    
65  node_t *  node_t *
66  list_remove(list_t *list, node_t *node)  list_remove(node_t *node, list_t *list)
67  {  {
68    /* Assumption: If node->next == NULL, then list->tail == node    /* Assumption: If node->next == NULL, then list->tail == node
69     *      and:   If node->prev == NULL, then list->head == node     *      and:   If node->prev == NULL, then list->head == node
# Line 81  list_remove(list_t *list, node_t *node) Line 85  list_remove(list_t *list, node_t *node)
85    }    }
86    
87    /* Set this to NULL does matter */    /* Set this to NULL does matter */
88    node->next = node->prev = NULL;    node->next = NULL;
89      node->prev = NULL;
90    list->elements--;    list->elements--;
91    
92    return node;    return node;
93  }  }
   
 void  
 node_free(node_t *node)  
 {  
   xfree(node);  
 }  

Legend:
Removed from v.8580  
changed lines
  Added in v.8581

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