- return 0;
-}
-
-static int mmap_cache_get_fd_index(MMapCache *m, int fd, unsigned *fd_index) {
- FileDescriptor *j;
-
- assert(m);
- assert(fd >= 0);
- assert(fd_index);
-
- j = bsearch(&fd, m->by_fd, m->n_fds, sizeof(m->by_fd[0]), fd_cmp);
- if (!j) {
- if (m->n_fds >= m->fds_max)
- return -E2BIG;
-
- j = m->by_fd + m->n_fds ++;
- j->fd = fd;
- j->windows = (unsigned) -1;
-
- qsort(m->by_fd, m->n_fds, sizeof(m->by_fd[0]), fd_cmp);
- j = bsearch(&fd, m->by_fd, m->n_fds, sizeof(m->by_fd[0]), fd_cmp);
- }
-
- *fd_index = (unsigned) (j - m->by_fd);
- return 0;
-}
-
-static bool mmap_cache_test_window(
- MMapCache *m,
- unsigned w,
- uint64_t offset,
- uint64_t size) {
- Window *v;
-
- assert(m);
- assert(w < m->n_windows);
- assert(size > 0);
-
- v = m->windows + w;
-
- return offset >= v->offset &&
- offset + size <= v->offset + v->size;