drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
mf_sort.cc
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
15
16/* Sort of string pointers in string-order with radix or qsort */
17
18#include <config.h>
19
20#include <drizzled/internal/my_sys.h>
21#include <drizzled/internal/m_string.h>
22
23namespace drizzled {
24namespace internal {
25
26void my_string_ptr_sort(unsigned char *base, uint32_t items, size_t size)
27{
28#if INT_MAX > 65536L
29 if (size <= 20 && items >= 1000 && items < 100000)
30 {
31 unsigned char** ptr= (unsigned char**) malloc(items*sizeof(char*));
32 radixsort_for_str_ptr((unsigned char**) base,items,size,ptr);
33 free((unsigned char*) ptr);
34 }
35 else
36#else
37 assert(false);
38#endif
39 {
40 if (size && items)
41 {
42 my_qsort2(base,items, sizeof(unsigned char*), get_ptr_compare(size),
43 (void*) &size);
44 }
45 }
46}
47
48} /* namespace internal */
49} /* namespace drizzled */
TODO: Rename this file - func.h is stupid.