sbase

suckless unix tools
git clone git://git.2f30.org/sbase
Log | Files | Refs | README | LICENSE

commit fe6144793fe7d2a4d674204f675d2e48a2fe06d2
parent 38f429a3d26122af61b73a8965b1e8e9043c0a0c
Author: sin <sin@2f30.org>
Date:   Mon, 20 Jan 2014 11:25:57 +0000

Check mmap() return value and unmap at the end

Diffstat:
Mtr.c | 4++++
1 file changed, 4 insertions(+), 0 deletions(-)

diff --git a/tr.c b/tr.c @@ -124,6 +124,8 @@ main(int argc, char *argv[]) mappings = (wchar_t *)mmap(NULL, 0x110000 * sizeof(wchar_t), PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, -1, 0); + if (mappings == MAP_FAILED) + eprintf("mmap:"); ARGBEGIN { default: @@ -147,5 +149,7 @@ main(int argc, char *argv[]) if(ferror(stdin)) eprintf("<stdin>: read error:"); + munmap(mappings, 0x110000 * sizeof(wchar_t)); + return EXIT_SUCCESS; }