]> git.saurik.com Git - wxWidgets.git/commitdiff
implemented bsearch() for CE; added src/msw/wince/crt.cpp
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 4 Apr 2004 12:30:54 +0000 (12:30 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 4 Apr 2004 12:30:54 +0000 (12:30 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@26596 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

build/bakefiles/files.bkl
src/msw/wince/crt.cpp [new file with mode: 0644]

index 53fc4d9207a2d8eed7e6e0b943755d4d614169c7..7d53cc7ad05204375bfae15b679a3909bdd26358 100644 (file)
@@ -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 (file)
index 0000000..058e7b2
--- /dev/null
@@ -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 <vadim@wxwindows.org>
+// 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;
+}
+
+