2005-12-05 Charles Mills, Hans Boehm <Hans.Boehm@hp.com>
authorhboehm <hboehm>
Tue, 6 Dec 2005 01:07:16 +0000 (01:07 +0000)
committerIvan Maidanski <ivmai@mail.ru>
Tue, 26 Jul 2011 17:06:35 +0000 (21:06 +0400)
Make GlobalAlloc address alignment a bit more intuitive.

doc/README.changes
os_dep.c

index ebdbe63..2d01b02 100644 (file)
@@ -2443,6 +2443,8 @@ Since gc7.0alpha5
    (more 6.7 changes)
  - Declare GC_dump() in gc.h.
  - Add --enable-large-config, which just defines the LARGE_CONFIG macro.
+ - Make GlobalAlloc address alignment a bit more intuitive.  (Thanks to
+   Charles Mills.)
   
 To do:
  - REDIRECT_MALLOC and threads combination is getting closer, but currently
index c2a25f3..eb82ee2 100644 (file)
--- a/os_dep.c
+++ b/os_dep.c
@@ -1703,7 +1703,7 @@ ptr_t GC_win32_get_mem(word bytes)
        /* There are also unconfirmed rumors of other           */
        /* problems, so we dodge the issue.                     */
         result = (ptr_t) GlobalAlloc(0, bytes + HBLKSIZE);
-        result = (ptr_t)(((word)result + HBLKSIZE) & ~(HBLKSIZE-1));
+        result = (ptr_t)(((word)result + HBLKSIZE - 1) & ~(HBLKSIZE-1));
     } else {
        /* VirtualProtect only works on regions returned by a   */
        /* single VirtualAlloc call.  Thus we allocate one      */