From 449cc351536a62a07e73500702bf1d685473b277 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 27 Oct 2011 21:10:48 +0000 Subject: [PATCH] Don't make wxQsort() extern "C" nor use any special convention for it. It doesn't make sense to require passing C functions to wxQsort() that we define in a C++ library. We also don't need any special calling convention here. Notice that the only existing uses of wxQsort() inside wxWidgets itself were not actually extern "C" and one of them didn't even use the correct calling convention. Also avoid using non-wx-prefixed CMPFUNCDATA identifier in a public header, rename it to wxSortCallback instead. Finally make wxQsort() documentation slightly more useful. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@69566 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/utils.h | 12 ++++++------ include/wx/vector.h | 2 +- interface/wx/utils.h | 16 ++++++++-------- src/common/utilscmn.cpp | 2 +- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/include/wx/utils.h b/include/wx/utils.h index b539373de9..9d254ca589 100644 --- a/include/wx/utils.h +++ b/include/wx/utils.h @@ -588,14 +588,14 @@ WXDLLIMPEXP_BASE bool wxGetDiskSpace(const wxString& path, -extern "C" -{ -typedef int (wxCMPFUNC_CONV *CMPFUNCDATA)(const void* pItem1, const void* pItem2, const void* user_data); -} +typedef int (*wxSortCallback)(const void* pItem1, + const void* pItem2, + const void* user_data); -WXDLLIMPEXP_BASE void wxQsort(void *const pbase, size_t total_elems, - size_t size, CMPFUNCDATA cmp, const void* user_data); +WXDLLIMPEXP_BASE void wxQsort(void* pbase, size_t total_elems, + size_t size, wxSortCallback cmp, + const void* user_data); #if wxUSE_GUI // GUI only things from now on diff --git a/include/wx/vector.h b/include/wx/vector.h index 8cf76d9ff6..e95d4103ef 100644 --- a/include/wx/vector.h +++ b/include/wx/vector.h @@ -457,7 +457,7 @@ namespace wxPrivate template struct wxVectorComparator { - static int wxCMPFUNC_CONV + static int Compare(const void* pitem1, const void* pitem2, const void* ) { const T& item1 = *reinterpret_cast(pitem1); diff --git a/interface/wx/utils.h b/interface/wx/utils.h index 120ed37cc3..fc02d7594f 100644 --- a/interface/wx/utils.h +++ b/interface/wx/utils.h @@ -496,19 +496,19 @@ void wxPostDelete(wxObject* object); @header{wx/utils.h} */ -extern "C" -{ -typedef int (wxCMPFUNC_CONV *CMPFUNCDATA)(const void* pItem1, const void* pItem2, const void* user_data); -} +typedef int (*wxSortCallback)(const void* pItem1, const void* pItem2, const void* user_data); /** - Function for performing a qsort operation including a user data - parameter. + Function implementing quick sort algorithm. + + This function sorts @a total_elems objects of size @a size located at @a + pbase. It uses @a cmp function for comparing them and passes @a user_data + pointer to the comparison function each time it's called. @header{wx/utils.h} */ -void wxQsort(void *const pbase, size_t total_elems, - size_t size, CMPFUNCDATA cmp, const void* user_data); +void wxQsort(void* pbase, size_t total_elems, + size_t size, wxSortCallback cmp, const void* user_data); /** diff --git a/src/common/utilscmn.cpp b/src/common/utilscmn.cpp index 17b6eb5879..389c87769b 100644 --- a/src/common/utilscmn.cpp +++ b/src/common/utilscmn.cpp @@ -815,7 +815,7 @@ typedef struct stack size is needed (actually O(1) in this case)! */ void wxQsort(void *const pbase, size_t total_elems, - size_t size, CMPFUNCDATA cmp, const void* user_data) + size_t size, wxSortCallback cmp, const void* user_data) { register char *base_ptr = (char *) pbase; const size_t max_thresh = MAX_THRESH * size; -- 2.47.2