- // Seek to the right offset
- r = fseek(f, offset, SEEK_SET);
- if (r)
- return r;
-
- size_t bytes_read = fread(pool->data, sizeof(*pool->data), length, f);
- if (bytes_read < length) {
- ERROR(pool->ctx, "Could not read pool. Only read %zu bytes\n", bytes_read);
- return 1;
- }
+ pool->data = pool->pos = mmap(NULL, length, PROT_READ,
+ MAP_PRIVATE, fileno(f), offset);
+ pool->max_length = length;