Drizzled Public API Documentation

mf_sort.cc
00001 /* Copyright (C) 2000 MySQL AB
00002 
00003    This program is free software; you can redistribute it and/or modify
00004    it under the terms of the GNU General Public License as published by
00005    the Free Software Foundation; version 2 of the License.
00006 
00007    This program is distributed in the hope that it will be useful,
00008    but WITHOUT ANY WARRANTY; without even the implied warranty of
00009    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00010    GNU General Public License for more details.
00011 
00012    You should have received a copy of the GNU General Public License
00013    along with this program; if not, write to the Free Software
00014    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
00015 
00016 /* Sort of string pointers in string-order with radix or qsort */
00017 
00018 #include <config.h>
00019 
00020 #include <drizzled/internal/my_sys.h>
00021 #include <drizzled/internal/m_string.h>
00022 
00023 namespace drizzled {
00024 namespace internal {
00025 
00026 void my_string_ptr_sort(unsigned char *base, uint32_t items, size_t size)
00027 {
00028 #if INT_MAX > 65536L
00029   if (size <= 20 && items >= 1000 && items < 100000)
00030   {
00031     unsigned char** ptr= (unsigned char**) malloc(items*sizeof(char*));
00032     radixsort_for_str_ptr((unsigned char**) base,items,size,ptr);
00033     free((unsigned char*) ptr);
00034   }
00035   else
00036 #else
00037   assert(false);
00038 #endif
00039   {
00040     if (size && items)
00041     {
00042       my_qsort2(base,items, sizeof(unsigned char*), get_ptr_compare(size),
00043                 (void*) &size);
00044     }
00045   }
00046 }
00047 
00048 } /* namespace internal */
00049 } /* namespace drizzled */