~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/filesort.cc

  • Committer: Brian Aker
  • Date: 2008-12-05 03:17:16 UTC
  • mfrom: (641.3.11 devel)
  • Revision ID: brian@tangent.org-20081205031716-r65xkzugjylmvv1h
Monty merge (a couple of alterations for malloc()).

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
/* functions defined in this file */
33
33
 
34
34
static char **make_char_array(char **old_pos, register uint32_t fields,
35
 
                              uint32_t length, myf my_flag);
 
35
                              uint32_t length);
36
36
static unsigned char *read_buffpek_from_file(IO_CACHE *buffer_file, uint32_t count,
37
37
                                     unsigned char *buf);
38
38
static ha_rows find_all_keys(SORTPARAM *param,SQL_SELECT *select,
153
153
  if (param.addon_field)
154
154
  {
155
155
    param.res_length= param.addon_length;
156
 
    if (!(table_sort.addon_buf= (unsigned char *) my_malloc(param.addon_length,
157
 
                                                    MYF(MY_WME))))
 
156
    if (!(table_sort.addon_buf= (unsigned char *) malloc(param.addon_length)))
158
157
      goto err;
159
158
  }
160
159
  else
198
197
  }
199
198
 
200
199
  if (multi_byte_charset &&
201
 
      !(param.tmp_buffer= (char*) my_malloc(param.sort_length,MYF(MY_WME))))
 
200
      !(param.tmp_buffer= (char*) malloc(param.sort_length)))
202
201
    goto err;
203
202
 
204
203
  memavl= session->variables.sortbuff_size;
210
209
    param.keys=(uint32_t) cmin(records+1, keys);
211
210
    if ((table_sort.sort_keys=
212
211
         (unsigned char **) make_char_array((char **) table_sort.sort_keys,
213
 
                                    param.keys, param.rec_length, MYF(0))))
 
212
                                            param.keys, param.rec_length)))
214
213
      break;
215
214
    old_memavl=memavl;
216
215
    if ((memavl=memavl/4*3) < min_sort_memory && old_memavl > min_sort_memory)
360
359
/** Make a array of string pointers. */
361
360
 
362
361
static char **make_char_array(char **old_pos, register uint32_t fields,
363
 
                              uint32_t length, myf my_flag)
 
362
                              uint32_t length)
364
363
{
365
364
  register char **pos;
366
365
  char *char_pos;
367
366
 
368
367
  if (old_pos ||
369
 
      (old_pos= (char**) my_malloc((uint32_t) fields*(length+sizeof(char*)),
370
 
                                   my_flag)))
 
368
      (old_pos= (char**) malloc((uint32_t) fields*(length+sizeof(char*)))))
371
369
  {
372
370
    pos=old_pos; char_pos=((char*) (pos+fields)) -length;
373
371
    while (fields--) *(pos++) = (char_pos+= length);
387
385
  if (count > UINT_MAX/sizeof(BUFFPEK))
388
386
    return 0; /* sizeof(BUFFPEK)*count will overflow */
389
387
  if (!tmp)
390
 
    tmp= (unsigned char *)my_malloc(length, MYF(MY_WME));
 
388
    tmp= (unsigned char *)malloc(length);
391
389
  if (tmp)
392
390
  {
393
391
    if (reinit_io_cache(buffpek_pointers,READ_CACHE,0L,0,0) ||
966
964
  if ((ha_rows) count > param->max_rows)
967
965
    count=(uint32_t) param->max_rows;
968
966
  if (!(to= table_sort->record_pointers= 
969
 
        (unsigned char*) my_malloc(res_length*count, MYF(MY_WME))))
 
967
        (unsigned char*) malloc(res_length*count)))
970
968
    return(1);                 /* purecov: inspected */
971
969
  for (unsigned char **end= sort_keys+count ; sort_keys != end ; sort_keys++)
972
970
  {
1498
1496
  length+= (null_fields+7)/8;
1499
1497
 
1500
1498
  if (length+sortlength > session->variables.max_length_for_sort_data ||
1501
 
      !(addonf= (SORT_ADDON_FIELD *) my_malloc(sizeof(SORT_ADDON_FIELD)*
1502
 
                                               (fields+1), MYF(MY_WME))))
 
1499
      !(addonf= (SORT_ADDON_FIELD *) malloc(sizeof(SORT_ADDON_FIELD)*
 
1500
                                            (fields+1))))
1503
1501
    return 0;
1504
1502
 
1505
1503
  *plength= length;