Preparatory commit; callers manually ref/unref MMapCaches
alongside MMapFileDescriptor add/frees, when the latter should be
sufficient.
A subsequent commit will drop some of those manual MMapCache
reference hoop-jumping, leaving the lifecycle bound to
MMapFileDescriptors.
if (!f)
return NULL;
- f->cache = m;
- f->fd = fd;
- f->prot = prot;
-
r = hashmap_put(m->fds, FD_TO_PTR(fd), f);
if (r < 0)
return mfree(f);
+ f->cache = mmap_cache_ref(m);
+ f->fd = fd;
+ f->prot = prot;
+
return f;
}
while (f->windows)
window_free(f->windows);
- if (f->cache)
+ if (f->cache) {
assert_se(hashmap_remove(f->cache->fds, FD_TO_PTR(f->fd)));
+ f->cache = mmap_cache_unref(f->cache);
+ }
free(f);
}