From: Vadim Zeitlin Date: Sun, 4 Apr 2004 12:30:54 +0000 (+0000) Subject: implemented bsearch() for CE; added src/msw/wince/crt.cpp X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/e3bf2e8cac58d01d6c6a3e486eb5482184be175b implemented bsearch() for CE; added src/msw/wince/crt.cpp git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@26596 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/build/bakefiles/files.bkl b/build/bakefiles/files.bkl index 53fc4d9207..7d53cc7ad0 100644 --- a/build/bakefiles/files.bkl +++ b/build/bakefiles/files.bkl @@ -1314,6 +1314,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! src/generic/dirdlgg.cpp src/generic/fdrepdlg.cpp src/generic/fontdlgg.cpp + src/msw/wince/crt.cpp src/msw/wince/filedlgwce.cpp src/msw/wince/helpwce.cpp src/msw/wince/tbarwce.cpp diff --git a/src/msw/wince/crt.cpp b/src/msw/wince/crt.cpp new file mode 100644 index 0000000000..058e7b260a --- /dev/null +++ b/src/msw/wince/crt.cpp @@ -0,0 +1,45 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: wince/crt.cpp +// Purpose: Implementation of CRT functions missing under Windows CE +// Author: Vadim Zeitlin +// Modified by: +// Created: 03.04.04 +// RCS-ID: +// Copyright: (c) 2004 Vadim Zeitlin +// Licence: wxWindows licence +/////////////////////////////////////////////////////////////////////////////// + +#include "wx/msw/wince/missing.h" + +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +extern "C" void * +bsearch(const void *key, const void *base, size_t num, size_t size, + int (wxCMPFUNC_CONV *cmp)(const void *, const void *)) +{ + int res; + char *mid; + + char *lo = (char *)base; + char *hi = lo + num*size; + while ( lo < hi ) + { + mid = lo + (hi - lo)/2; + + res = (*cmp)(key, mid); + if ( res < 0 ) + hi = mid; + else if ( res > 0 ) + lo = mid + size; + else // res == 0 + return mid; + } + + return NULL; +} + +