Skip to content

Commit

Permalink
* kern/mm.c (grub_real_malloc): Put magic and size assignment in common
Browse files Browse the repository at this point in the history
	part.
  • Loading branch information
phcoder committed May 3, 2010
1 parent 9b058d5 commit 7dd5a11
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2010-05-01 Vladimir Serbinenko <[email protected]>

* kern/mm.c (grub_real_malloc): Put magic and size assignment in common
part.

2010-05-01 Vladimir Serbinenko <[email protected]>

* kern/mm.c (grub_mm_init_region): Check for region size after aligning
Expand Down
12 changes: 3 additions & 9 deletions kern/mm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -242,14 +241,10 @@ 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;
Expand All @@ -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
{
Expand Down Expand Up @@ -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. */
Expand Down

0 comments on commit 7dd5a11

Please sign in to comment.