changeset 405:576967cbd064 HEAD

bugfix/cleanup
author Timo Sirainen <tss@iki.fi>
date Thu, 10 Oct 2002 05:07:55 +0300
parents f25e575bf1ca
children d12fa0b21a59
files src/lib/mmap-anon.c
diffstat 1 files changed, 10 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib/mmap-anon.c	Thu Oct 10 05:01:34 2002 +0300
+++ b/src/lib/mmap-anon.c	Thu Oct 10 05:07:55 2002 +0300
@@ -123,17 +123,22 @@
 
 	if (movable_mmap_base == NULL) {
 		/* this is fully guessing */
-		movable_mmap_base = ((char *) mmap_anon) + MMAP_BASE_MOVE;
 		movable_mmap_base = (char *) NULL +
-			PAGE_ALIGN((size_t)((char *) movable_mmap_base - NULL));
+			PAGE_ALIGN((size_t)((char *)mmap_anon - (char *)NULL));
 	}
 
 	do {
-		ret = anon_mmap_fixed(movable_mmap_base, length);
+		movable_mmap_base = (char *) movable_mmap_base +
+			MMAP_BASE_MOVE;
 		hdr = movable_mmap_base;
 
-		movable_mmap_base = (char *) movable_mmap_base +
-			MMAP_BASE_MOVE;
+		if (movable_mmap_base != NULL)
+			ret = anon_mmap_fixed(movable_mmap_base, length);
+		else {
+			/* we can't use NULL address */
+			errno = EINVAL;
+			ret = -1;
+		}
 
 	} while (ret == -1 && errno == EINVAL);