~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/my_file.cc

  • Committer: Brian Aker
  • Date: 2009-02-02 23:10:18 UTC
  • mfrom: (779.3.40 devel)
  • Revision ID: brian@tangent.org-20090202231018-zlp0hka6kgwy1vfy
Merge from Monty

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
#define RLIM_INFINITY ((uint) 0xffffffff)
41
41
#endif
42
42
 
43
 
static uint32_t set_max_open_files(uint32_t max_file_limit)
 
43
static uint64_t set_max_open_files(uint64_t max_file_limit)
44
44
{
45
45
  struct rlimit rlimit;
46
46
  rlim_t old_cur;
72
72
}
73
73
 
74
74
#else
75
 
static int set_max_open_files(uint32_t max_file_limit)
 
75
static int set_max_open_files(uint64_t max_file_limit)
76
76
{
77
77
  /* We don't know the limit. Return best guess */
78
78
  return cmin(max_file_limit, OS_FILE_LIMIT);
91
91
    number of files available for open
92
92
*/
93
93
 
94
 
uint32_t my_set_max_open_files(uint32_t files)
 
94
uint64_t my_set_max_open_files(uint64_t files)
95
95
{
96
96
  struct st_my_file_info *tmp;
97
97
 
99
99
  if (files <= MY_NFILE)
100
100
    return(files);
101
101
 
102
 
  if (!(tmp= (st_my_file_info*) malloc(sizeof(st_my_file_info) * files)))
 
102
  if (!(tmp= (st_my_file_info*) malloc((size_t)cmax(sizeof(st_my_file_info) * files,SIZE_MAX))))
103
103
    return(MY_NFILE);
104
104
 
105
105
  /* Copy any initialized files */
106
 
  memcpy(tmp, my_file_info, sizeof(*tmp) * cmin(my_file_limit, files));
 
106
  memcpy(tmp, my_file_info,
 
107
         sizeof(*tmp) *
 
108
            (size_t)cmin(my_file_limit,
 
109
                 cmax(files,UINT32_MAX)));
107
110
  /*
108
111
    The int cast is necessary since 'my_file_limits' might be greater
109
112
    than 'files'.
112
115
         cmax((int) (files - my_file_limit), 0)*sizeof(*tmp));
113
116
  my_free_open_file_info();                     /* Free if already allocated */
114
117
  my_file_info= tmp;
115
 
  my_file_limit= files;
 
118
  my_file_limit= (size_t)cmax(UINT32_MAX,files);
116
119
  return(files);
117
120
}
118
121