]> sourceware.org Git - dm.git/commitdiff
fix debug linking
authorAlasdair Kergon <agk@redhat.com>
Thu, 10 Nov 2005 16:33:04 +0000 (16:33 +0000)
committerAlasdair Kergon <agk@redhat.com>
Thu, 10 Nov 2005 16:33:04 +0000 (16:33 +0000)
lib/libdevmapper.h
lib/mm/dbg_malloc.c

index 75e19f891dcbc1536dc59e37120121befc922220..f8c1525385ed07131736c15cd82232e6388c0786 100644 (file)
@@ -342,23 +342,26 @@ int dm_tree_node_add_target_area(struct dm_tree_node *node,
  * Memory management
  *******************/
 
-void *dm_malloc_aux(size_t s, const char *file, int line);
-#define dm_malloc(s) dm_malloc_aux((s), __FILE__, __LINE__)
-
 char *dm_strdup(const char *str);
 
-#ifdef DEBUG_MEM
-
+void *dm_malloc_aux(size_t s, const char *file, int line);
+void *dm_malloc_aux_debug(size_t s, const char *file, int line);
 void dm_free_aux(void *p);
 void *dm_realloc_aux(void *p, unsigned int s, const char *file, int line);
-int dm_dump_memory(void);
-void dm_bounds_check(void);
+int dm_dump_memory_debug(void);
+void dm_bounds_check_debug(void);
+
+#ifdef DEBUG_MEM
 
+#  define dm_malloc(s) dm_malloc_aux_debug((s), __FILE__, __LINE__)
 #  define dm_free(p) dm_free_aux(p)
 #  define dm_realloc(p, s) dm_realloc_aux(p, s, __FILE__, __LINE__)
+#  define dm_dump_memory_debug()
+#  define dm_bounds_check_debug()
 
 #else
 
+#  define dm_malloc(s) dm_malloc_aux((s), __FILE__, __LINE__)
 #  define dm_free(p) free(p)
 #  define dm_realloc(p, s) realloc(p, s)
 #  define dm_dump_memory()
@@ -366,6 +369,7 @@ void dm_bounds_check(void);
 
 #endif
 
+
 /*
  * The pool allocator is useful when you are going to allocate
  * lots of memory, use the memory for a bit, and then free the
index 2e9ac9400e2b26b9a4f8f3d078e3ecab036075ff..6c872974f481183f2d4722a6a254d263763e4f48 100644 (file)
@@ -28,8 +28,6 @@ char *dm_strdup(const char *str)
        return ret;
 }
 
-#ifdef DEBUG_MEM
-
 struct memblock {
        struct memblock *prev, *next;   /* All allocated blocks are linked */
        size_t length;          /* Size of the requested block */
@@ -51,7 +49,7 @@ static struct {
 static struct memblock *_head = 0;
 static struct memblock *_tail = 0;
 
-void *dm_malloc_aux(size_t s, const char *file, int line)
+void *dm_malloc_aux_debug(size_t s, const char *file, int line)
 {
        struct memblock *nb;
        size_t tsize = s + sizeof(*nb) + sizeof(unsigned long);
@@ -72,9 +70,7 @@ void *dm_malloc_aux(size_t s, const char *file, int line)
        nb->file = file;
        nb->line = line;
 
-#ifdef BOUNDS_CHECK
        dm_bounds_check();
-#endif
 
        /* setup fields */
        nb->magic = nb + 1;
@@ -125,9 +121,7 @@ void dm_free_aux(void *p)
        if (!p)
                return;
 
-#ifdef BOUNDS_CHECK
        dm_bounds_check();
-#endif
 
        /* sanity check */
        assert(mb->magic == p);
@@ -171,7 +165,7 @@ void *dm_realloc_aux(void *p, unsigned int s, const char *file, int line)
        void *r;
        struct memblock *mb = ((struct memblock *) p) - 1;
 
-       r = dm_malloc_aux(s, file, line);
+       r = dm_malloc_aux_debug(s, file, line);
 
        if (p) {
                memcpy(r, p, mb->length);
@@ -181,7 +175,7 @@ void *dm_realloc_aux(void *p, unsigned int s, const char *file, int line)
        return r;
 }
 
-int dm_dump_memory(void)
+int dm_dump_memory_debug(void)
 {
        unsigned long tot = 0;
        struct memblock *mb;
@@ -216,7 +210,7 @@ int dm_dump_memory(void)
        return 1;
 }
 
-void dm_bounds_check(void)
+void dm_bounds_check_debug(void)
 {
        struct memblock *mb = _head;
        while (mb) {
@@ -230,8 +224,6 @@ void dm_bounds_check(void)
        }
 }
 
-#else
-
 void *dm_malloc_aux(size_t s, const char *file, int line)
 {
        if (s > 50000000) {
@@ -242,5 +234,3 @@ void *dm_malloc_aux(size_t s, const char *file, int line)
 
        return malloc(s);
 }
-
-#endif
This page took 0.028847 seconds and 5 git commands to generate.