* kern/mm.c (grub_real_malloc): Put magic and size assignment in common
part.
This commit is contained in:
parent
9b058d5291
commit
7dd5a111ba
2 changed files with 8 additions and 9 deletions
|
@ -1,3 +1,8 @@
|
|||
2010-05-01 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* kern/mm.c (grub_real_malloc): Put magic and size assignment in common
|
||||
part.
|
||||
|
||||
2010-05-01 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* kern/mm.c (grub_mm_init_region): Check for region size after aligning
|
||||
|
|
12
kern/mm.c
12
kern/mm.c
|
@ -220,7 +220,6 @@ grub_real_malloc (grub_mm_header_t *first, grub_size_t n, grub_size_t align)
|
|||
+---------------+ v
|
||||
*/
|
||||
q->next = p->next;
|
||||
p->magic = GRUB_MM_ALLOC_MAGIC;
|
||||
}
|
||||
else if (align == 1 || p->size == n + extra)
|
||||
{
|
||||
|
@ -242,15 +241,11 @@ grub_real_malloc (grub_mm_header_t *first, grub_size_t n, grub_size_t align)
|
|||
|
||||
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;
|
||||
|
||||
r = p + extra + n;
|
||||
r->magic = GRUB_MM_FREE_MAGIC;
|
||||
r->size = p->size - extra - n;
|
||||
|
@ -262,8 +257,6 @@ grub_real_malloc (grub_mm_header_t *first, grub_size_t n, grub_size_t align)
|
|||
q = r;
|
||||
r->next = r;
|
||||
}
|
||||
|
||||
p->size = n;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -296,10 +289,11 @@ grub_real_malloc (grub_mm_header_t *first, grub_size_t n, grub_size_t align)
|
|||
p->size = extra;
|
||||
p->next = r;
|
||||
p += extra;
|
||||
p->size = n;
|
||||
p->magic = GRUB_MM_ALLOC_MAGIC;
|
||||
}
|
||||
|
||||
p->magic = GRUB_MM_ALLOC_MAGIC;
|
||||
p->size = n;
|
||||
|
||||
/* Mark find as a start marker for next allocation to fasten it.
|
||||
This will have side effect of fragmenting memory as small
|
||||
pieces before this will be un-used. */
|
||||
|
|
Loading…
Reference in a new issue