summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Fonseca <[email protected]>2008-06-24 10:58:55 +0900
committerJosé Fonseca <[email protected]>2008-06-24 11:00:01 +0900
commit182b644c71462d86be2f2c79c9ff3fa636b7470a (patch)
tree0b287150ce0624aaaeb8616deccd73edfb89450d
parentc921a29b3a696f6fa99b648d6cd975dbcf106429 (diff)
mesa: bsearch implementation for WinCE.
-rw-r--r--src/mesa/main/imports.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c
index d798f80e253..c46e5beb918 100644
--- a/src/mesa/main/imports.c
+++ b/src/mesa/main/imports.c
@@ -765,7 +765,24 @@ void *
_mesa_bsearch( const void *key, const void *base, size_t nmemb, size_t size,
int (*compar)(const void *, const void *) )
{
+#if defined(_WIN32_WCE)
+ void *mid;
+ int cmp;
+ while (nmemb) {
+ nmemb >>= 1;
+ mid = (char *)base + nmemb * size;
+ cmp = (*compar)(key, mid);
+ if (cmp == 0)
+ return mid;
+ if (cmp > 0) {
+ base = (char *)mid + size;
+ --nmemb;
+ }
+ }
+ return NULL;
+#else
return bsearch(key, base, nmemb, size, compar);
+#endif
}
/*@}*/
@@ -781,7 +798,7 @@ _mesa_bsearch( const void *key, const void *base, size_t nmemb, size_t size,
char *
_mesa_getenv( const char *var )
{
-#if defined(_XBOX)
+#if defined(_XBOX) || defined(_WIN32_WCE)
return NULL;
#else
return getenv(var);