get-rusage-as: Improvement for Cygwin.
authorBruno Haible <bruno@clisp.org>
Tue, 18 Jan 2011 18:47:37 +0000 (19:47 +0100)
committerBruno Haible <bruno@clisp.org>
Tue, 18 Jan 2011 18:47:37 +0000 (19:47 +0100)
* lib/get-rusage-as.c (get_rusage_as_via_iterator): On Windows, ignore
areas that are merely reserved.

ChangeLog
lib/get-rusage-as.c

index 783de42c1e2289abf70ced8530a691d94f34b3b1..f997119174d227359c46527278e52bb002d9c89f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2011-01-18  Bruno Haible  <bruno@clisp.org>
+
+       get-rusage-as: Improvement for Cygwin.
+       * lib/get-rusage-as.c (get_rusage_as_via_iterator): On Windows, ignore
+       areas that are merely reserved.
+
 2011-01-18  Paul Eggert  <eggert@cs.ucla.edu>
 
        strftime: remove dependencies on multibyte modules
index 3ca13660084b883f707d851d619f5f14313368d6..7ab1c93153f71360228ed122eeef48dc8dcd8568 100644 (file)
@@ -653,7 +653,11 @@ get_rusage_as_via_iterator (void)
   while (VirtualQuery ((void*)address, &info, sizeof(info)) == sizeof(info))
     {
       if (info.State != MEM_FREE)
-        total += info.RegionSize;
+        /* Ignore areas where info.Protect has the undocumented value 0.
+           This is needed, so that on Cygwin, areas used by malloc() are
+           distinguished from areas reserved for future malloc().  */
+        if (info.Protect != 0)
+          total += info.RegionSize;
       address = (unsigned long)info.BaseAddress + info.RegionSize;
     }
   return total;