From 55c2d5b5314f3007202c67003eb99d7d92dedb7e Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Thu, 2 Feb 2012 16:20:32 +0100 Subject: [PATCH] further little clarifications in mmalloc comments --- src/xbt/mmalloc/mmalloc.c | 3 ++- src/xbt/mmalloc/mmemalign.c | 4 ++-- src/xbt/mmalloc/mmorecore.c | 16 +++++++--------- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/xbt/mmalloc/mmalloc.c b/src/xbt/mmalloc/mmalloc.c index 23db293271..82876e5b27 100644 --- a/src/xbt/mmalloc/mmalloc.c +++ b/src/xbt/mmalloc/mmalloc.c @@ -32,7 +32,8 @@ static void *align(struct mdesc *mdp, size_t size) * complete the reservation by also asking for the full lastest block. * * Also, the returned block is aligned to the end of block (but I've - * no fucking idea of why, actually -- http://abstrusegoose.com/432). + * no fucking idea of why, actually -- http://abstrusegoose.com/432 -- + * but not doing so seems to lead to issues). */ adj = RESIDUAL(result, BLOCKSIZE); if (adj != 0) { diff --git a/src/xbt/mmalloc/mmemalign.c b/src/xbt/mmalloc/mmemalign.c index cf0cef7d40..3b600be102 100644 --- a/src/xbt/mmalloc/mmemalign.c +++ b/src/xbt/mmalloc/mmemalign.c @@ -24,9 +24,9 @@ void *mmemalign(xbt_mheap_t mdp, size_t alignment, size_t size) break; } } - if (l == NULL) { + if (l == NULL) { /* No empty entry. Create & link a new one */ l = (struct alignlist *) mmalloc(mdp, sizeof(struct alignlist)); - if (l == NULL) { + if (l == NULL) { /* malloc error */ mfree(mdp, result); return (NULL); } diff --git a/src/xbt/mmalloc/mmorecore.c b/src/xbt/mmalloc/mmorecore.c index 9d78336d0b..9f31583e6f 100644 --- a/src/xbt/mmalloc/mmorecore.c +++ b/src/xbt/mmalloc/mmorecore.c @@ -113,17 +113,15 @@ void *mmorecore(struct mdesc *mdp, int size) MAP_PRIVATE_OR_SHARED(mdp) | MAP_IS_ANONYMOUS(mdp) | MAP_FIXED, MAP_ANON_OR_FD(mdp), foffset); - if (mapto != (void *) -1/* That's MAP_FAILED */) { + if (mapto == (void *) -1/* That's MAP_FAILED */) + THROWF(system_error,0,"mmap returned MAP_FAILED! error: %s",strerror(errno)); - if (mdp->top == 0) - mdp->base = mdp->breakval = mapto; + if (mdp->top == 0) + mdp->base = mdp->breakval = mapto; - mdp->top = PAGE_ALIGN((char *) mdp->breakval + size); - result = (void *) mdp->breakval; - mdp->breakval = (char *) mdp->breakval + size; - } else { - THROWF(system_error,0,"mmap returned MAP_FAILED! error: %s",strerror(errno)); - } + mdp->top = PAGE_ALIGN((char *) mdp->breakval + size); + result = (void *) mdp->breakval; + mdp->breakval = (char *) mdp->breakval + size; } else { result = (void *) mdp->breakval; mdp->breakval = (char *) mdp->breakval + size; -- 2.20.1