#include <sys/mman.h>
#include "alloc-util.h"
+#include "errno-util.h"
#include "fd-util.h"
#include "hashmap.h"
#include "list.h"
#include "log.h"
#include "macro.h"
+#include "memory-util.h"
#include "mmap-cache.h"
#include "sigbus.h"
-#include "util.h"
typedef struct Window Window;
typedef struct Context Context;
free(w);
}
-_pure_ static inline bool window_matches(Window *w, int prot, uint64_t offset, size_t size) {
+_pure_ static bool window_matches(Window *w, int prot, uint64_t offset, size_t size) {
assert(w);
assert(size > 0);
if (!m->last_unused || m->n_windows <= WINDOWS_MIN) {
/* Allocate a new window */
- w = new0(Window, 1);
+ w = new(Window, 1);
if (!w)
return NULL;
m->n_windows++;
/* Reuse an existing one */
w = m->last_unused;
window_unlink(w);
- zero(*w);
}
- w->cache = m;
- w->fd = f;
- w->prot = prot;
- w->keep_always = keep_always;
- w->offset = offset;
- w->size = size;
- w->ptr = ptr;
+ *w = (Window) {
+ .cache = m,
+ .fd = f,
+ .prot = prot,
+ .keep_always = keep_always,
+ .offset = offset,
+ .size = size,
+ .ptr = ptr,
+ };
LIST_PREPEND(by_fd, f->windows, w);