]> sourceware.org Git - lvm2.git/commitdiff
Some fixes to memory debugging code.
authorAlasdair Kergon <agk@redhat.com>
Thu, 16 Sep 2004 16:53:39 +0000 (16:53 +0000)
committerAlasdair Kergon <agk@redhat.com>
Thu, 16 Sep 2004 16:53:39 +0000 (16:53 +0000)
Exclude internal commands formats & segtypes from install.

WHATS_NEW
lib/mm/dbg_malloc.c
lib/mm/pool-debug.c
tools/Makefile.in

index 843f9f07243337ec29567c29e1fb741e2ca3a133..83fe0dc649314f7f06e4faabb2c4e9dce085566d 100644 (file)
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,7 @@
 Version 2.00.24 - 
 =====================================
+  Some fixes to memory debugging code.
+  Exclude internal commands formats & segtypes from install.
 
 Version 2.00.23 - 15th September 2004
 =====================================
index 42f434acf1b3f344d1576cd878b5c00c2750864e..47cecf8c000aa497903a18356a5d2fcd3c214a4f 100644 (file)
@@ -29,11 +29,13 @@ struct memblock {
 };
 
 static struct {
-       unsigned int blocks, mblocks;
+       unsigned block_serialno;/* Non-decreasing serialno of block */
+       unsigned blocks_allocated; /* Current number of blocks allocated */
+       unsigned blocks_max;    /* Max no of concurrently-allocated blocks */
        unsigned int bytes, mbytes;
 
 } _mem_stats = {
-0, 0, 0, 0};
+0, 0, 0, 0, 0};
 
 static struct memblock *_head = 0;
 static struct memblock *_tail = 0;
@@ -65,7 +67,7 @@ void *malloc_aux(size_t s, const char *file, int line)
        /* setup fields */
        nb->magic = nb + 1;
        nb->length = s;
-       nb->id = ++_mem_stats.blocks;
+       nb->id = ++_mem_stats.block_serialno;
        nb->next = 0;
        nb->prev = _tail;
 
@@ -89,8 +91,9 @@ void *malloc_aux(size_t s, const char *file, int line)
                        *ptr++ = (char) nb->id;
        }
 
-       if (_mem_stats.blocks > _mem_stats.mblocks)
-               _mem_stats.mblocks = _mem_stats.blocks;
+       _mem_stats.blocks_allocated++;
+       if (_mem_stats.blocks_allocated > _mem_stats.blocks_max)
+               _mem_stats.blocks_max = _mem_stats.blocks_allocated;
 
        _mem_stats.bytes += s;
        if (_mem_stats.bytes > _mem_stats.mbytes)
@@ -140,8 +143,8 @@ void free_aux(void *p)
        else
                _tail = mb->prev;
 
-       assert(_mem_stats.blocks);
-       _mem_stats.blocks--;
+       assert(_mem_stats.blocks_allocated);
+       _mem_stats.blocks_allocated--;
        _mem_stats.bytes -= mb->length;
 
        /* free the memory */
index 482a1a290ba3df930935ce0b778bb7b1bd825ffa..a56f24a07132b29597c8b88e61661aad78f36572 100644 (file)
@@ -83,7 +83,7 @@ static void _append_block(struct pool *p, struct block *b)
 
 static struct block *_new_block(size_t s, unsigned alignment)
 {
-       static char *_oom = "Out of memory";
+       static const char *_oom = "Out of memory";
 
        /* FIXME: I'm currently ignoring the alignment arg. */
        size_t len = sizeof(struct block) + s;
@@ -180,10 +180,13 @@ int pool_grow_object(struct pool *p, const void *buffer, size_t delta)
 
        if (p->object) {
                memcpy(new->data, p->object->data, p->object->size);
+               dbg_free(p->object->data);
                dbg_free(p->object);
        }
        p->object = new;
 
+       memcpy(new->data + size - delta, buffer, delta);
+
        return 1;
 }
 
index ce8ff20365e34c40501c9e2e274674cf359df0b8..05eb5147235a18c8b6d073f2e3f9ed0f86a0cd27 100644 (file)
@@ -109,7 +109,7 @@ liblvm2cmd.so: liblvm2cmd.a $(LDDEPS)
 
 .commands: commands.h cmdnames.h Makefile
        $(CC) -E -P cmdnames.h 2> /dev/null | \
-               egrep -v '^ *(|#.*|dumpconfig|help|pvdata|version) *$$' > .commands
+               egrep -v '^ *(|#.*|dumpconfig|formats|help|pvdata|segtypes|version) *$$' > .commands
 
 .PHONY: install_cmdlib_dynamic install_cmdlib_static \
        install_tools_dynamic install_tools_static
This page took 0.062065 seconds and 5 git commands to generate.