[PATCH] Remove unused malloc debugging code

Frodo Baggins frodo.drogo at gmail.com
Tue Sep 4 12:32:05 UTC 2007


---
 libparted/libparted.c |   70 -------------------------------------------------
 1 files changed, 0 insertions(+), 70 deletions(-)

diff --git a/libparted/libparted.c b/libparted/libparted.c
index a8c7f0a..8b0fb5a 100644
--- a/libparted/libparted.c
+++ b/libparted/libparted.c
@@ -51,27 +51,6 @@ typedef struct
     size_t     size;
 } pointer_size_type;

-/* IMHO, none of the DEBUG-related code below is useful, and the
-   ped_malloc memset code is actually quite harmful: it masked at
-   least two nasty bugs that were fixed in June of 2007.  */
-#undef DEBUG
-#ifdef DEBUG
-static pointer_size_type dodgy_malloc_list[] = {
- {0,           0},
- {0,           0},
- {0,           0},
- {0,           0},
- {0,           0},
- {0,           0},
- {0,           0},
- {0,           0},
- {0,           0},
- {0,           0}
-};
-
-static int     dodgy_memory_active[100];
-#endif /* DEBUG */
-
 int
 ped_set_architecture (const PedArchitecture* arch)
 {
@@ -199,9 +178,6 @@ _init()
        ped_set_architecture (&ped_gnu_arch);
 #endif

-#ifdef DEBUG
-       memset (dodgy_memory_active, 0, sizeof (dodgy_memory_active));
-#endif
 }

 #ifdef ENABLE_FS
@@ -252,42 +228,6 @@ ped_get_version ()
        return VERSION;
 }

-#ifdef DEBUG
-static void
-_check_dodgy_pointer (const void* ptr, size_t size, int is_malloc)
-{
-       int             i;
-
-       for (i=0; dodgy_malloc_list[i].pointer; i++) {
-               if (dodgy_malloc_list[i].pointer != ptr)
-                       continue;
-               if (is_malloc && dodgy_malloc_list[i].size != size)
-                       continue;
-               if (!is_malloc && !dodgy_memory_active[i])
-                       continue;
-
-
-               if (is_malloc) {
-                       ped_exception_throw (
-                               PED_EXCEPTION_INFORMATION,
-                               PED_EXCEPTION_OK,
-                               "Dodgy malloc(%x) == %p occurred (active==%d)",
-                               size, ptr, dodgy_memory_active[i]);
-                       dodgy_memory_active[i]++;
-               } else {
-                       ped_exception_throw (
-                               PED_EXCEPTION_INFORMATION,
-                               PED_EXCEPTION_OK,
-                               "Dodgy free(%p) occurred (active==%d)",
-                               ptr, dodgy_memory_active[i]);
-                       dodgy_memory_active[i]--;
-               }
-
-               return;
-       }
-}
-#endif /* DEBUG */
-
 void*
 ped_malloc (size_t size)
 {
@@ -299,12 +239,6 @@ ped_malloc (size_t size)
                                     _("Out of memory."));
                return NULL;
        }
-
-#ifdef DEBUG
-       memset (mem, 0xff, size);
-       _check_dodgy_pointer (mem, size, 1);
-#endif
-
        return mem;
 }

@@ -337,9 +271,5 @@ void* ped_calloc (size_t size)
 void
 ped_free (void* ptr)
 {
-#ifdef DEBUG
-       _check_dodgy_pointer (ptr, 0, 0);
-#endif
-
        free (ptr);
 }
--
1.4.3.4



More information about the parted-devel mailing list