~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
/* Copyright (C) 2000 MySQL AB
2
3
   This program is free software; you can redistribute it and/or modify
4
   it under the terms of the GNU General Public License as published by
5
   the Free Software Foundation; version 2 of the License.
6
7
   This program is distributed in the hope that it will be useful,
8
   but WITHOUT ANY WARRANTY; without even the implied warranty of
9
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
   GNU General Public License for more details.
11
12
   You should have received a copy of the GNU General Public License
13
   along with this program; if not, write to the Free Software
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
16
/* Sort of string pointers in string-order with radix or qsort */
17
994.2.4 by Monty Taylor
Blast. Fixed some make distcheck issues.
18
#include "mysys/mysys_priv.h"
212.5.18 by Monty Taylor
Moved m_ctype, m_string and my_bitmap. Removed t_ctype.
19
#include <mystrings/m_string.h>
1 by brian
clean slate
20
482 by Brian Aker
Remove uint.
21
void my_string_ptr_sort(unsigned char *base, uint32_t items, size_t size)
1 by brian
clean slate
22
{
23
#if INT_MAX > 65536L
481 by Brian Aker
Remove all of uchar.
24
  unsigned char **ptr= NULL;
1 by brian
clean slate
25
26
  if (size <= 20 && items >= 1000 && items < 100000 &&
656.1.26 by Monty Taylor
Finally removed all of the my_malloc stuff.
27
      (ptr= (unsigned char**) malloc(items*sizeof(char*))))
1 by brian
clean slate
28
  {
481 by Brian Aker
Remove all of uchar.
29
    radixsort_for_str_ptr((unsigned char**) base,items,size,ptr);
30
    free((unsigned char*) ptr);
1 by brian
clean slate
31
  }
32
  else
33
#endif
34
  {
35
    if (size && items)
36
    {
481 by Brian Aker
Remove all of uchar.
37
      my_qsort2(base,items, sizeof(unsigned char*), get_ptr_compare(size),
1 by brian
clean slate
38
                (void*) &size);
39
    }
40
  }
41
}