Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Simplify the malloc_info structure containing the metadata of a given block in mmalloc
[simgrid.git] / src / xbt / mmalloc / mmorecore.c
index 9d78336..9e2d22e 100644 (file)
@@ -21,7 +21,6 @@
 #include <sys/mman.h>
 
 #include "mmprivate.h"
-#include "xbt/ex.h"
 
 /* Cache the pagesize for the current host machine.  Note that if the host
    does not readily provide a getpagesize() function, we need to emulate it
@@ -113,17 +112,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;