diff options
author | Jan Huwald <jh@sotun.de> | 2013-06-14 11:21:53 (GMT) |
---|---|---|
committer | Jan Huwald <jh@sotun.de> | 2013-06-14 11:21:53 (GMT) |
commit | a5d69600f7fb83a415de0a2ef3d1d9205e402021 (patch) | |
tree | 93afc2353f89ef28cfdd33f7c43198cf8ba2d730 | |
parent | a7c4309240e41964e15d23eb5fc4c1b3aeebc6d6 (diff) |
mmalloc: unlink tmp file after opening
Otherwise it would hang around when the program stops and waste the
precious hugetlbfs space (read: RAM).
-rw-r--r-- | mmalloc.hpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/mmalloc.hpp b/mmalloc.hpp index a794a34..8e2ac93 100644 --- a/mmalloc.hpp +++ b/mmalloc.hpp @@ -10,14 +10,14 @@ void *r; char tmpName[] = "/mnt/hugetlbfs/mmallocXXXXXX"; int fd = mkstemp(tmpName); if (fd < 0) goto fail1; - if (ftruncate(fd, size) != 0) goto fail2; + if (unlink(tmpName) != 0) goto fail2; r = mmap(NULL, - size, - PROT_READ | PROT_WRITE, - MAP_SHARED | MAP_POPULATE, - fd, 0); + size, + PROT_READ | PROT_WRITE, + MAP_SHARED | MAP_POPULATE, + fd, 0); if (r == MAP_FAILED) goto fail2; return r; |