~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/list.c

  • Committer: Monty Taylor
  • Date: 2008-08-02 01:03:15 UTC
  • mto: (236.1.42 codestyle)
  • mto: This revision was merged to the branch mainline in revision 261.
  • Revision ID: monty@inaugust.com-20080802010315-65h5938pymg9d99z
Moved m4 macros to top-level m4 dir, per GNU standards (and where gettext wanted it :)

Show diffs side-by-side

added added

removed removed

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