~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/list.c

  • Committer: Monty Taylor
  • Date: 2008-08-04 19:37:18 UTC
  • mto: (261.2.2 codestyle)
  • mto: This revision was merged to the branch mainline in revision 262.
  • Revision ID: monty@inaugust.com-20080804193718-f0rz13uli4429ozb
Changed gettext_noop() to N_()

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
  Code for handling dubble-linked lists in C
18
18
*/
19
19
 
20
 
#include <stdlib.h>
21
20
#include "mysys_priv.h"
22
21
#include <my_list.h>
23
22
 
53
52
}
54
53
 
55
54
 
56
 
void list_free(LIST *root, uint32_t free_data)
 
55
void list_free(LIST *root, uint free_data)
57
56
{
58
57
  LIST *next;
59
58
  while (root)
60
59
  {
61
60
    next=root->next;
62
61
    if (free_data)
63
 
      free((unsigned char*) root->data);
64
 
    free((unsigned char*) root);
 
62
      my_free((uchar*) root->data,MYF(0));
 
63
    my_free((uchar*) root,MYF(0));
65
64
    root=next;
66
65
  }
67
66
}
69
68
 
70
69
LIST *list_cons(void *data, LIST *list)
71
70
{
72
 
  LIST * const new_charset=(LIST*) my_malloc(sizeof(LIST),MYF(MY_FAE));
 
71
  LIST *new_charset=(LIST*) my_malloc(sizeof(LIST),MYF(MY_FAE));
73
72
  if (!new_charset)
74
 
    return NULL;
 
73
    return 0;
75
74
  new_charset->data=data;
76
75
  return list_add(list,new_charset);
77
76
}
92
91
  return last;
93
92
}
94
93
 
95
 
int list_walk(LIST *list, list_walk_action action, unsigned char* argument)
96
 
{
 
94
uint list_length(LIST *list)
 
95
{
 
96
  uint count;
 
97
  for (count=0 ; list ; list=list->next, count++) ;
 
98
  return count;
 
99
}
 
100
 
 
101
 
 
102
int list_walk(LIST *list, list_walk_action action, uchar* argument)
 
103
{
 
104
  int error=0;
97
105
  while (list)
98
106
  {
99
 
    int error;
100
107
    if ((error = (*action)(list->data,argument)))
101
108
      return error;
102
109
    list=list_rest(list);