summaryrefslogtreecommitdiff
path: root/src/libdatastruct/avlnode_search.c
blob: 85073ca2077bb409bb9d45a71158bd81fa75c507 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/* ISC license. */

#include <stdint.h>
#include <errno.h>
#include <skalibs/functypes.h>
#include <skalibs/avlnode.h>

int avlnode_search (avlnode const *s, uint32_t max, uint32_t r, void const *k, uint32_t *data, dtokfunc_t_ref dtok, cmpfunc_t_ref f, void *p)
{
  uint32_t i = avlnode_searchnode(s, max, r, k, dtok, f, p) ;
  if (i >= max) return (errno = ESRCH, 0) ;
  *data = s[i].data ;
  return 1 ;
}