From 7ee8c21b9eaa4f6981cf727729c415b4a5c310f3 Mon Sep 17 00:00:00 2001 From: David Phillips Date: Wed, 11 May 2016 18:36:37 +1200 Subject: Catch mmap error --- fractal-gen.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/fractal-gen.c b/fractal-gen.c index 30f405b..38e2a08 100644 --- a/fractal-gen.c +++ b/fractal-gen.c @@ -80,13 +80,12 @@ int main(int argc, char **argv) } /* Allocate memory for sections */ -/* if ((sections = malloc(sizeof(data_section)*cores)) == NULL)*/ - sections = mmap(NULL, sizeof(data_section)*cores, PROT_READ|PROT_WRITE, - MAP_SHARED|MAP_ANONYMOUS, -1, 0); -/* { + if ((sections = mmap(NULL, sizeof(data_section)*cores, PROT_READ|PROT_WRITE, + MAP_SHARED|MAP_ANONYMOUS, -1, 0)) == (data_section*)MAP_FAILED) + { perror("mmap"); return 1; - }*/ + } ram_nice = (size*size)/clust_total; if (ram_nice < 1024) -- cgit v1.1