summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Fonseca <[email protected]>2008-06-24 10:58:55 +0900
committerKeith Whitwell <[email protected]>2008-09-21 22:13:56 -0700
commitbaa76e9aa255c4b4591111991b6ad6d80e69d9c1 (patch)
tree5ce031cdf623351556a46928ed93cd54f508daae
parent2e8af5ffcf5b59b6852cf0c7ad992af97de13fce (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 7f2fca7e1da..13cb84ca4bf 100644
--- a/src/mesa/main/imports.c
+++ b/src/mesa/main/imports.c
@@ -786,7 +786,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
}
/*@}*/
@@ -802,7 +819,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);