From 3ce27299eb500d06a62215f9449526a54ea676f0 Mon Sep 17 00:00:00 2001 From: hollisb Date: Tue, 20 Feb 2007 22:39:57 +0000 Subject: [PATCH] 2007-02-20 Hollis Blanchard * kern/mm.c: Update copyright. (grub_mm_debug): Correct syntax error. (grub_mm_dump_free): New function. (grub_debug_free): Call `grub_free'. * include/grub/mm.h: Update copyright. (grub_mm_dump_free): Add declaration. --- ChangeLog | 9 +++++++++ include/grub/mm.h | 3 ++- kern/mm.c | 31 +++++++++++++++++++++++++++++-- 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index a12ce00e8..9a782a613 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2007-02-20 Hollis Blanchard + + * kern/mm.c: Update copyright. + (grub_mm_debug): Correct syntax error. + (grub_mm_dump_free): New function. + (grub_debug_free): Call `grub_free'. + * include/grub/mm.h: Update copyright. + (grub_mm_dump_free): Add declaration. + 2007-02-12 Hollis Blanchard * include/grub/ieee1275/ieee1275.h: Update copyright. diff --git a/include/grub/mm.h b/include/grub/mm.h index 81f7eb875..a29fad237 100644 --- a/include/grub/mm.h +++ b/include/grub/mm.h @@ -1,7 +1,7 @@ /* mm.h - prototypes and declarations for memory manager */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2002 Free Software Foundation, Inc. + * Copyright (C) 2002,2007 Free Software Foundation, Inc. * * GRUB is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -40,6 +40,7 @@ void *EXPORT_FUNC(grub_memalign) (grub_size_t align, grub_size_t size); /* Set this variable to 1 when you want to trace all memory function calls. */ extern int EXPORT_VAR(grub_mm_debug); +void grub_mm_dump_free (void); void grub_mm_dump (unsigned lineno); #define grub_malloc(size) \ diff --git a/kern/mm.c b/kern/mm.c index cf921c899..c8a636976 100644 --- a/kern/mm.c +++ b/kern/mm.c @@ -1,7 +1,7 @@ /* mm.c - functions for memory manager */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2002,2005 Free Software Foundation, Inc. + * Copyright (C) 2002,2005,2007 Free Software Foundation, Inc. * * GRUB is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -396,7 +396,33 @@ grub_realloc (void *ptr, grub_size_t size) } #ifdef MM_DEBUG -grub_mm_debug = 0; +int grub_mm_debug = 0; + +void +grub_mm_dump_free (void) +{ + grub_mm_region_t r; + + for (r = base; r; r = r->next) + { + grub_mm_header_t p; + + /* Follow the free list. */ + p = r->first; + do + { + if (p->magic != GRUB_MM_FREE_MAGIC) + grub_fatal ("free magic is broken at %p: 0x%x", p, p->magic); + + grub_printf ("F:%p:%u:%p\n", + p, (unsigned int) p->size << GRUB_MM_ALIGN_LOG2, p->next); + p = p->next; + } + while (p != r->first); + } + + grub_printf ("\n"); +} void grub_mm_dump (unsigned lineno) @@ -447,6 +473,7 @@ grub_debug_free (const char *file, int line, void *ptr) { if (grub_mm_debug) grub_printf ("%s:%d: free (%p)\n", file, line, ptr); + grub_free (ptr); } void * -- 2.39.5