* 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>
|
2010-05-01 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
* kern/mm.c (grub_mm_init_region): Check for region size after aligning
|
* 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
|
+---------------+ v
|
||||||
*/
|
*/
|
||||||
q->next = p->next;
|
q->next = p->next;
|
||||||
p->magic = GRUB_MM_ALLOC_MAGIC;
|
|
||||||
}
|
}
|
||||||
else if (align == 1 || p->size == n + extra)
|
else if (align == 1 || p->size == n + extra)
|
||||||
{
|
{
|
||||||
|
@ -242,14 +241,10 @@ grub_real_malloc (grub_mm_header_t *first, grub_size_t n, grub_size_t align)
|
||||||
|
|
||||||
p->size -= n;
|
p->size -= n;
|
||||||
p += p->size;
|
p += p->size;
|
||||||
p->size = n;
|
|
||||||
p->magic = GRUB_MM_ALLOC_MAGIC;
|
|
||||||
}
|
}
|
||||||
else if (extra == 0)
|
else if (extra == 0)
|
||||||
{
|
{
|
||||||
grub_mm_header_t r;
|
grub_mm_header_t r;
|
||||||
|
|
||||||
p->magic = GRUB_MM_ALLOC_MAGIC;
|
|
||||||
|
|
||||||
r = p + extra + n;
|
r = p + extra + n;
|
||||||
r->magic = GRUB_MM_FREE_MAGIC;
|
r->magic = GRUB_MM_FREE_MAGIC;
|
||||||
|
@ -262,8 +257,6 @@ grub_real_malloc (grub_mm_header_t *first, grub_size_t n, grub_size_t align)
|
||||||
q = r;
|
q = r;
|
||||||
r->next = r;
|
r->next = r;
|
||||||
}
|
}
|
||||||
|
|
||||||
p->size = n;
|
|
||||||
}
|
}
|
||||||
else
|
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->size = extra;
|
||||||
p->next = r;
|
p->next = r;
|
||||||
p += extra;
|
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.
|
/* Mark find as a start marker for next allocation to fasten it.
|
||||||
This will have side effect of fragmenting memory as small
|
This will have side effect of fragmenting memory as small
|
||||||
pieces before this will be un-used. */
|
pieces before this will be un-used. */
|
||||||
|
|
Loading…
Reference in a new issue