~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/list.c

  • Committer: Brian Aker
  • Date: 2008-07-13 21:20:24 UTC
  • Revision ID: brian@tangent.org-20080713212024-o6263c1vha7yxdeu
More bool removal. More cow bell!

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
 
27
27
LIST *list_add(LIST *root, LIST *element)
28
28
{
 
29
  DBUG_ENTER("list_add");
 
30
  DBUG_PRINT("enter",("root: 0x%lx  element: 0x%lx", (long) root, (long) element));
29
31
  if (root)
30
32
  {
31
33
    if (root->prev)                     /* If add in mid of list */
36
38
  else
37
39
    element->prev=0;
38
40
  element->next=root;
39
 
  return(element);                      /* New root */
 
41
  DBUG_RETURN(element);                 /* New root */
40
42
}
41
43
 
42
44
 
52
54
}
53
55
 
54
56
 
55
 
void list_free(LIST *root, uint32_t free_data)
 
57
void list_free(LIST *root, uint free_data)
56
58
{
57
59
  LIST *next;
58
60
  while (root)
59
61
  {
60
62
    next=root->next;
61
63
    if (free_data)
62
 
      free((unsigned char*) root->data);
63
 
    free((unsigned char*) root);
 
64
      my_free((uchar*) root->data,MYF(0));
 
65
    my_free((uchar*) root,MYF(0));
64
66
    root=next;
65
67
  }
66
68
}
68
70
 
69
71
LIST *list_cons(void *data, LIST *list)
70
72
{
71
 
  LIST * const new_charset=(LIST*) my_malloc(sizeof(LIST),MYF(MY_FAE));
 
73
  LIST *new_charset=(LIST*) my_malloc(sizeof(LIST),MYF(MY_FAE));
72
74
  if (!new_charset)
73
 
    return NULL;
 
75
    return 0;
74
76
  new_charset->data=data;
75
77
  return list_add(list,new_charset);
76
78
}
91
93
  return last;
92
94
}
93
95
 
94
 
int list_walk(LIST *list, list_walk_action action, unsigned char* argument)
95
 
{
 
96
uint list_length(LIST *list)
 
97
{
 
98
  uint count;
 
99
  for (count=0 ; list ; list=list->next, count++) ;
 
100
  return count;
 
101
}
 
102
 
 
103
 
 
104
int list_walk(LIST *list, list_walk_action action, uchar* argument)
 
105
{
 
106
  int error=0;
96
107
  while (list)
97
108
  {
98
 
    int error;
99
109
    if ((error = (*action)(list->data,argument)))
100
110
      return error;
101
111
    list=list_rest(list);