~drizzle-trunk/drizzle/jenkins-Drizzle-Builder-213

« back to all changes in this revision

Viewing changes to plugin/myisam/sort.cc

  • Committer: Olaf van der Spek
  • Date: 2011-08-13 14:36:27 UTC
  • mto: This revision was merged to the branch mainline in revision 2407.
  • Revision ID: olafvdspek@gmail.com-20110813143627-j92kghasif1w2xe4
Refactor DYNAMIC_ARRAY

Show diffs side-by-side

added added

removed removed

Lines of Context:
154
154
      while ((maxbuffer= (size_t)(records/(keys-1)+1)) != skr);
155
155
 
156
156
    sort_keys=(unsigned char **)malloc(keys*(sort_length+sizeof(char*)));
157
 
    my_init_dynamic_array(&buffpek, sizeof(BUFFPEK), maxbuffer, maxbuffer/2);
 
157
    buffpek.init(sizeof(BUFFPEK), maxbuffer, maxbuffer/2);
158
158
    break;
159
159
  }
160
160
  if (memavl < MIN_SORT_MEMORY)
228
228
 
229
229
err:
230
230
  free(sort_keys);
231
 
  delete_dynamic(&buffpek);
 
231
  buffpek.free();
232
232
  tempfile.close_cached_file();
233
233
  tempfile_for_exceptions.close_cached_file();
234
234
 
235
 
  return(error ? -1 : 0);
 
235
  return error ? -1 : 0;
236
236
} /* _create_index_by_sort */
237
237
 
238
238
 
261
261
 
262
262
    if (++idx == keys)
263
263
    {
264
 
      if (info->write_keys(info,sort_keys,idx-1,(BUFFPEK *)alloc_dynamic(buffpek),
265
 
                     tempfile))
266
 
      return(HA_POS_ERROR);
 
264
      if (info->write_keys(info,sort_keys,idx-1,(BUFFPEK *)buffpek->alloc(), tempfile))
 
265
        return HA_POS_ERROR;
267
266
 
268
267
      sort_keys[0]=(unsigned char*) (sort_keys+keys);
269
268
      memcpy(sort_keys[0],sort_keys[idx-1],(size_t) info->key_length);
275
274
    return(HA_POS_ERROR);
276
275
  if (buffpek->size())
277
276
  {
278
 
    if (info->write_keys(info,sort_keys,idx,(BUFFPEK *)alloc_dynamic(buffpek),
279
 
                   tempfile))
280
 
      return(HA_POS_ERROR);
 
277
    if (info->write_keys(info,sort_keys,idx,(BUFFPEK *)buffpek->alloc(), tempfile))
 
278
      return HA_POS_ERROR;
281
279
    *maxbuffer=buffpek->size() - 1;
282
280
  }
283
281
  else
336
334
    sinfo->sort_keys=0;
337
335
  }
338
336
 
339
 
  for (i= 0, sinfo= sort_param ;
340
 
       i < sort_info->total_keys ;
341
 
       i++,
342
 
         delete_dynamic(&sinfo->buffpek),
 
337
  for (i= 0, sinfo= sort_param; i < sort_info->total_keys; i++,
 
338
         sinfo->buffpek.free(),
343
339
         sinfo->tempfile.close_cached_file(),
344
340
         sinfo->tempfile_for_exceptions.close_cached_file(),
345
341
         sinfo++)