X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=nss%2Ffile.c;h=5dba688caeac4df5618a7b6c810dbd1cbf454efb;hb=1002c514a8530bb6608c556b4446e853be390917;hp=6da0fd656663a6402db230d0f57a11b4abeb88d8;hpb=0d99032f2a22b97cd7c49bfba4a6cd0b41fd87d6;p=nsscash%2Fnsscash.git diff --git a/nss/file.c b/nss/file.c index 6da0fd6..5dba688 100644 --- a/nss/file.c +++ b/nss/file.c @@ -1,7 +1,7 @@ /* * Load and unload nsscash files * - * Copyright (C) 2019 Simon Ruderich + * Copyright (C) 2019-2020 Simon Ruderich * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -41,8 +41,9 @@ bool map_file(const char *path, struct file *f) { if (fstat(f->fd, &s)) { goto fail; } - f->size = (size_t)s.st_size; + f->size = (size_t)s.st_size; // for munmap() + // mmap is used for speed and simple random access void *x = mmap(NULL, f->size, PROT_READ, MAP_PRIVATE, f->fd, 0); if (x == MAP_FAILED) { goto fail;