1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

Some fixes to memory debugging code.

Exclude internal commands formats & segtypes from install.
This commit is contained in:
Alasdair Kergon 2004-09-16 16:53:39 +00:00
parent 5b3d93c86d
commit e26c4fd2a2
4 changed files with 17 additions and 9 deletions

View File

@ -1,5 +1,7 @@
Version 2.00.24 - Version 2.00.24 -
===================================== =====================================
Some fixes to memory debugging code.
Exclude internal commands formats & segtypes from install.
Version 2.00.23 - 15th September 2004 Version 2.00.23 - 15th September 2004
===================================== =====================================

View File

@ -29,11 +29,13 @@ struct memblock {
}; };
static struct { 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; unsigned int bytes, mbytes;
} _mem_stats = { } _mem_stats = {
0, 0, 0, 0}; 0, 0, 0, 0, 0};
static struct memblock *_head = 0; static struct memblock *_head = 0;
static struct memblock *_tail = 0; static struct memblock *_tail = 0;
@ -65,7 +67,7 @@ void *malloc_aux(size_t s, const char *file, int line)
/* setup fields */ /* setup fields */
nb->magic = nb + 1; nb->magic = nb + 1;
nb->length = s; nb->length = s;
nb->id = ++_mem_stats.blocks; nb->id = ++_mem_stats.block_serialno;
nb->next = 0; nb->next = 0;
nb->prev = _tail; nb->prev = _tail;
@ -89,8 +91,9 @@ void *malloc_aux(size_t s, const char *file, int line)
*ptr++ = (char) nb->id; *ptr++ = (char) nb->id;
} }
if (_mem_stats.blocks > _mem_stats.mblocks) _mem_stats.blocks_allocated++;
_mem_stats.mblocks = _mem_stats.blocks; if (_mem_stats.blocks_allocated > _mem_stats.blocks_max)
_mem_stats.blocks_max = _mem_stats.blocks_allocated;
_mem_stats.bytes += s; _mem_stats.bytes += s;
if (_mem_stats.bytes > _mem_stats.mbytes) if (_mem_stats.bytes > _mem_stats.mbytes)
@ -140,8 +143,8 @@ void free_aux(void *p)
else else
_tail = mb->prev; _tail = mb->prev;
assert(_mem_stats.blocks); assert(_mem_stats.blocks_allocated);
_mem_stats.blocks--; _mem_stats.blocks_allocated--;
_mem_stats.bytes -= mb->length; _mem_stats.bytes -= mb->length;
/* free the memory */ /* free the memory */

View 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 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. */ /* FIXME: I'm currently ignoring the alignment arg. */
size_t len = sizeof(struct block) + s; 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) { if (p->object) {
memcpy(new->data, p->object->data, p->object->size); memcpy(new->data, p->object->data, p->object->size);
dbg_free(p->object->data);
dbg_free(p->object); dbg_free(p->object);
} }
p->object = new; p->object = new;
memcpy(new->data + size - delta, buffer, delta);
return 1; return 1;
} }

View File

@ -109,7 +109,7 @@ liblvm2cmd.so: liblvm2cmd.a $(LDDEPS)
.commands: commands.h cmdnames.h Makefile .commands: commands.h cmdnames.h Makefile
$(CC) -E -P cmdnames.h 2> /dev/null | \ $(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 \ .PHONY: install_cmdlib_dynamic install_cmdlib_static \
install_tools_dynamic install_tools_static install_tools_dynamic install_tools_static