Beispiel #1
0
static int internal_find(STACK *st, char *data, int ret_val_options)
	{
	char **r;
	int i;
	int (*comp_func)(const void *,const void *);
	if(st == NULL) return -1;

	if (st->comp == NULL)
		{
		for (i=0; i<st->num; i++)
			if (st->data[i] == data)
				return(i);
		return(-1);
		}
	sk_sort(st);
	if (data == NULL) return(-1);
	/* This (and the "qsort" below) are the two places in OpenSSL
	 * where we need to convert from our standard (type **,type **)
	 * compare callback type to the (void *,void *) type required by
	 * bsearch. However, the "data" it is being called(back) with are
	 * not (type *) pointers, but the *pointers* to (type *) pointers,
	 * so we get our extra level of pointer dereferencing that way. */
	comp_func=(int (*)(const void *,const void *))(st->comp);
	r=(char **)OBJ_bsearch_ex((char *)&data,(char *)st->data,
		st->num,sizeof(char *),comp_func,ret_val_options);
	if (r == NULL) return(-1);
	return((int)(r-st->data));
	}
Beispiel #2
0
const char *OBJ_bsearch(const char *key, const char *base, int num, int size,
  int (*cmp)(const void *, const void *))
  {
  return OBJ_bsearch_ex(key, base, num, size, cmp, 0);
  }