* 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) {
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);
}
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;