~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/my_file.c

  • Committer: Brian Aker
  • Date: 2008-09-04 19:31:00 UTC
  • Revision ID: brian@tangent.org-20080904193100-l849hgghfy4urj43
Changing default character set from this point on.

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
#define RLIM_INFINITY ((uint) 0xffffffff)
39
39
#endif
40
40
 
41
 
static uint32_t set_max_open_files(uint32_t max_file_limit)
 
41
static uint set_max_open_files(uint max_file_limit)
42
42
{
43
43
  struct rlimit rlimit;
44
 
  uint32_t old_cur;
 
44
  uint old_cur;
45
45
 
46
46
  if (!getrlimit(RLIMIT_NOFILE,&rlimit))
47
47
  {
65
65
}
66
66
 
67
67
#else
68
 
static int set_max_open_files(uint32_t max_file_limit)
 
68
static int set_max_open_files(uint max_file_limit)
69
69
{
70
70
  /* We don't know the limit. Return best guess */
71
 
  return cmin(max_file_limit, OS_FILE_LIMIT);
 
71
  return min(max_file_limit, OS_FILE_LIMIT);
72
72
}
73
73
#endif
74
74
 
84
84
    number of files available for open
85
85
*/
86
86
 
87
 
uint32_t my_set_max_open_files(uint32_t files)
 
87
uint my_set_max_open_files(uint files)
88
88
{
89
89
  struct st_my_file_info *tmp;
90
90
 
91
 
  files= set_max_open_files(cmin(files, OS_FILE_LIMIT));
 
91
  files= set_max_open_files(min(files, OS_FILE_LIMIT));
92
92
  if (files <= MY_NFILE)
93
93
    return(files);
94
94
 
97
97
    return(MY_NFILE);
98
98
 
99
99
  /* Copy any initialized files */
100
 
  memcpy(tmp, my_file_info, sizeof(*tmp) * cmin(my_file_limit, files));
 
100
  memcpy(tmp, my_file_info, sizeof(*tmp) * min(my_file_limit, files));
101
101
  /*
102
102
    The int cast is necessary since 'my_file_limits' might be greater
103
103
    than 'files'.
104
104
  */
105
105
  memset(tmp + my_file_limit, 0,
106
 
         cmax((int) (files - my_file_limit), 0)*sizeof(*tmp));
 
106
         max((int) (files - my_file_limit), 0)*sizeof(*tmp));
107
107
  my_free_open_file_info();                     /* Free if already allocated */
108
108
  my_file_info= tmp;
109
109
  my_file_limit= files;
118
118
    /* Copy data back for my_print_open_files */
119
119
    memcpy(my_file_info_default, my_file_info,
120
120
           sizeof(*my_file_info_default)* MY_NFILE);
121
 
    free((char*) my_file_info);
 
121
    my_free((char*) my_file_info, MYF(0));
122
122
    my_file_info= my_file_info_default;
123
123
    my_file_limit= MY_NFILE;
124
124
  }