Fixup our morecore implementation so that we deal with glibc trimming
correctly. A 0 increment is a request for the current heaptop and a
negative increment simply adjusts the heaptop (the return value is
actually ignored by glibc).

Signed-off-by: Nishanth Aravamudan <[EMAIL PROTECTED]>

diff --git a/morecore.c b/morecore.c
index 39322a6..ea6fb02 100644
--- a/morecore.c
+++ b/morecore.c
@@ -57,6 +57,18 @@ static void *hugetlbfs_morecore(ptrdiff_
 
        DEBUG("hugetlbfs_morecore(%ld) = ...\n", (long)increment);
 
+       if (increment == 0) {
+               DEBUG("Requesting current heaptop (%p)\n", heaptop);
+               return heaptop;
+       }
+
+       if (increment < 0) {
+               DEBUG("Trimming heap to ...\n");
+               heaptop = heaptop + increment;
+               DEBUG("... %p\n", heaptop);
+               return heaptop;
+       }
+
        /*
         * how much to grow the heap by =
         *      (size of heap) + malloc request - mmap'd space

-- 
Nishanth Aravamudan <[EMAIL PROTECTED]>
IBM Linux Technology Center

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Libhugetlbfs-devel mailing list
Libhugetlbfs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel

Reply via email to