PostgreSQL Source Code  git master
bsearch_arg.c File Reference
#include "c.h"
Include dependency graph for bsearch_arg.c:

Go to the source code of this file.

Functions

void * bsearch_arg (const void *key, const void *base0, size_t nmemb, size_t size, int(*compar)(const void *, const void *, void *), void *arg)
 

Function Documentation

◆ bsearch_arg()

void* bsearch_arg ( const void *  key,
const void *  base0,
size_t  nmemb,
size_t  size,
int(*)(const void *, const void *, void *)  compar,
void *  arg 
)

Definition at line 55 of file bsearch_arg.c.

59 {
60  const char *base = (const char *) base0;
61  int lim,
62  cmp;
63  const void *p;
64 
65  for (lim = nmemb; lim != 0; lim >>= 1)
66  {
67  p = base + (lim >> 1) * size;
68  cmp = (*compar) (key, p, arg);
69  if (cmp == 0)
70  return (void *) p;
71  if (cmp > 0)
72  { /* key > p: move right */
73  base = (const char *) p + size;
74  lim--;
75  } /* else move left */
76  }
77  return (NULL);
78 }
void * arg
static int cmp(const chr *x, const chr *y, size_t len)
Definition: regc_locale.c:743
static pg_noinline void Size size
Definition: slab.c:607

References arg, cmp(), sort-test::key, and size.

Referenced by AssertCheckRanges(), range_contains_value(), statext_mcv_build(), and statext_mcv_serialize().