ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

bsearch.c
Go to the documentation of this file.
00001 /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
00002 #include <stdlib.h>
00003 
00004 /*
00005  * @implemented
00006  */
00007 void *
00008 bsearch(const void *key, const void *base0, size_t nelem,
00009     size_t size, int (__cdecl *cmp)(const void *ck, const void *ce))
00010 {
00011   char *base = (char *)base0;
00012   size_t lim;
00013   int cmpval;
00014   void *p;
00015 
00016   for (lim = nelem; lim != 0; lim >>= 1)
00017   {
00018     p = base + (lim >> 1) * size;
00019     cmpval = (*cmp)(key, p);
00020     if (cmpval == 0)
00021       return p;
00022     if (cmpval > 0)
00023     {               /* key > p: move right */
00024       base = (char *)p + size;
00025       lim--;
00026     } /* else move left */
00027   }
00028   return 0;
00029 }

Generated on Sun May 27 2012 04:36:36 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.