]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/contrib/mmap.cc
The 'not dead yet' release
[apt.git] / apt-pkg / contrib / mmap.cc
index ba4482131d4c1fd7b5ddc4388d3b16c9b93ed0a1..229b18037c149ef2353ec2d5e4476e5f5704e0d7 100644 (file)
@@ -175,13 +175,14 @@ DynamicMMap::DynamicMMap(unsigned long Flags,unsigned long WorkSpace) :
 #ifdef _POSIX_MAPPED_FILES
    // use anonymous mmap() to get the memory
    Base = (unsigned char*) mmap(0, WorkSpace, PROT_READ|PROT_WRITE,
-                       MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
-   if(Base != MAP_FAILED)
+                                MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
+   if(Base == MAP_FAILED)
       return;
-#endif
+#else
    // fallback to a static allocated space
    Base = new unsigned char[WorkSpace];
    memset(Base,0,WorkSpace);
+#endif
    iSize = 0;
 }
                                                                        /*}}}*/
@@ -193,7 +194,7 @@ DynamicMMap::~DynamicMMap()
    if (Fd == 0)
    {
 #ifdef _POSIX_MAPPED_FILES
-      munmap(Base, WorkSpace);
+      if(munmap(Base, WorkSpace) < 0)
 #else
       delete [] (unsigned char *)Base;
 #endif