Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(168)

Unified Diff: third_party/minicrt/bsearch.c

Issue 624713003: Keep only base/extractor.[cc|h]. (Closed) Base URL: https://chromium.googlesource.com/external/omaha.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/minicrt/argcargv.cc ('k') | third_party/minicrt/build.scons » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
-}
« no previous file with comments | « third_party/minicrt/argcargv.cc ('k') | third_party/minicrt/build.scons » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698