PandA-2024.02
bsearch-specialized.c
Go to the documentation of this file.
1 typedef unsigned int size_t;
2 #define NULL 0
3 int less (const void * a, const void * b);
4 void *bsearch(const void *key, const void *base, size_t /* nmemb */ high,
5  size_t size, int (*compar)(const void *, const void *))
6 {
7  register char *p;
8  size_t low;
9  size_t mid;
10  int r;
11 
12  if (size > 0) { /* TODO: change this to an assert?? */
13  low = 0;
14  while (low < high) {
15  mid = low + ((high - low) >> 1); /* Avoid possible overflow here. */
16  p = ((char *)base) + mid * size; /* Could overflow here... */
17  r = less(key, p); /* but that's an application problem! */
18  if (r > 0) {
19  low = mid + 1;
20  } else if (r < 0) {
21  high = mid;
22  } else {
23  return p;
24  }
25  }
26  }
27  return NULL;
28 }
char base
This version is stamped on May 10, 2016.
Definition: nussinov.c:24
#define NULL
int key[32]
Definition: aes.h:67
void * bsearch(const void *__key, const void *__base, size_t __nmemb, size_t __size, int(*__compar)(const void *, const void *))
int compar(const void *v_lhs, const void *v_rhs)
Definition: generate.c:16
int less(const void *a, const void *b)
Definition: less.c:4
unsigned int size_t

Generated on Mon Feb 12 2024 13:02:49 for PandA-2024.02 by doxygen 1.8.13