]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* kern/mm.c (grub_real_malloc): Satisfy alignment requirement when
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sun, 14 Mar 2010 22:56:13 +0000 (23:56 +0100)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sun, 14 Mar 2010 22:56:13 +0000 (23:56 +0100)
        extra == 0.

ChangeLog.memalign_fix [new file with mode: 0644]
kern/mm.c

diff --git a/ChangeLog.memalign_fix b/ChangeLog.memalign_fix
new file mode 100644 (file)
index 0000000..3dac2e5
--- /dev/null
@@ -0,0 +1,4 @@
+2010-03-14  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       * kern/mm.c (grub_real_malloc): Satisfy alignment requirement when
+        extra == 0.
\ No newline at end of file
index ef97b018e9d7e91928078d5408c050527071391a..9720a8b9daa4e8c42225b490cf4911aa285eb07f 100644 (file)
--- a/kern/mm.c
+++ b/kern/mm.c
@@ -223,7 +223,7 @@ grub_real_malloc (grub_mm_header_t *first, grub_size_t n, grub_size_t align)
              q->next = p->next;
              p->magic = GRUB_MM_ALLOC_MAGIC;
            }
-         else if (extra == 0 || p->size == n + extra)
+         else if (align == 1 || p->size == n + extra)
            {
              /* There might be alignment requirement, when taking it into
                 account memory block fits in.
@@ -240,11 +240,25 @@ grub_real_malloc (grub_mm_header_t *first, grub_size_t n, grub_size_t align)
                 | alloc, size=n |        |
                 +---------------+        v
               */
+
              p->size -= n;
              p += p->size;
              p->size = n;
              p->magic = GRUB_MM_ALLOC_MAGIC;
            }
+         else if (extra == 0)
+           {
+             grub_mm_header_t r;
+
+             p->magic = GRUB_MM_ALLOC_MAGIC;
+             p->size = n;
+             
+             r = p + extra + n;
+             r->magic = GRUB_MM_FREE_MAGIC;
+             r->size = p->size - extra - n;
+             r->next = p->next;
+             q->next = r;
+           }
          else
            {
              /* There is alignment requirement and there is room in memory