| Index: third_party/minicrt/bsearch.c
|
| diff --git a/third_party/minicrt/bsearch.c b/third_party/minicrt/bsearch.c
|
| deleted file mode 100644
|
| index 1f80d8c511b28d93e7668379891c184151561e0d..0000000000000000000000000000000000000000
|
| --- a/third_party/minicrt/bsearch.c
|
| +++ /dev/null
|
| @@ -1,80 +0,0 @@
|
| -#include "libctiny.h"
|
| -#include <windows.h>
|
| -
|
| -/***
|
| -*bsearch.c - do a binary search
|
| -*
|
| -* Copyright (c) Microsoft Corporation. All rights reserved.
|
| -*
|
| -*Purpose:
|
| -* defines bsearch() - do a binary search an an array
|
| -*
|
| -*******************************************************************************/
|
| -
|
| -// #include <cruntime.h>
|
| -// #include <stdlib.h>
|
| -// #include <search.h>
|
| -
|
| -/***
|
| -*char *bsearch() - do a binary search on an array
|
| -*
|
| -*Purpose:
|
| -* Does a binary search of a sorted array for a key.
|
| -*
|
| -*Entry:
|
| -* const char *key - key to search for
|
| -* const char *base - base of sorted array to search
|
| -* unsigned int num - number of elements in array
|
| -* unsigned int width - number of bytes per element
|
| -* int (*compare)() - pointer to function that compares two array
|
| -* elements, returning neg when #1 < #2, pos when #1 > #2, and
|
| -* 0 when they are equal. Function is passed pointers to two
|
| -* array elements.
|
| -*
|
| -*Exit:
|
| -* if key is found:
|
| -* returns pointer to occurrence of key in array
|
| -* if key is not found:
|
| -* returns NULL
|
| -*
|
| -*Exceptions:
|
| -*
|
| -*******************************************************************************/
|
| -
|
| -void * __cdecl bsearch (
|
| - const void *key,
|
| - const void *base,
|
| - size_t num,
|
| - size_t width,
|
| - int (__cdecl *compare)(const void *, const void *)
|
| - )
|
| -{
|
| - register char *lo = (char *)base;
|
| - register char *hi = (char *)base + (num - 1) * width;
|
| - register char *mid;
|
| - size_t half;
|
| - int result;
|
| -
|
| - while (lo <= hi)
|
| - if (half = num / 2)
|
| - {
|
| - mid = lo + (num & 1 ? half : (half - 1)) * width;
|
| - if (!(result = (*compare)(key,mid)))
|
| - return(mid);
|
| - else if (result < 0)
|
| - {
|
| - hi = mid - width;
|
| - num = num & 1 ? half : half-1;
|
| - }
|
| - else {
|
| - lo = mid + width;
|
| - num = half;
|
| - }
|
| - }
|
| - else if (num)
|
| - return((*compare)(key,lo) ? NULL : lo);
|
| - else
|
| - break;
|
| -
|
| - return(NULL);
|
| -}
|
|
|