mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
Fix debug pool grow object to properly support delta=0
(It prints garbage for some reports)
This commit is contained in:
parent
ec5703ea07
commit
fe41c21be9
@ -218,14 +218,19 @@ int dm_pool_begin_object(struct dm_pool *p, size_t init_size)
|
||||
int dm_pool_grow_object(struct dm_pool *p, const void *extra, size_t delta)
|
||||
{
|
||||
struct block *new;
|
||||
size_t size = delta ? : strlen(extra);
|
||||
size_t new_size;
|
||||
|
||||
if (!delta)
|
||||
delta = strlen(extra);
|
||||
|
||||
assert(p->begun);
|
||||
|
||||
if (p->object)
|
||||
size += p->object->size;
|
||||
new_size = delta + p->object->size;
|
||||
else
|
||||
new_size = delta;
|
||||
|
||||
if (!(new = _new_block(size, DEFAULT_ALIGNMENT))) {
|
||||
if (!(new = _new_block(new_size, DEFAULT_ALIGNMENT))) {
|
||||
log_err("Couldn't extend object.");
|
||||
return 0;
|
||||
}
|
||||
@ -237,7 +242,7 @@ int dm_pool_grow_object(struct dm_pool *p, const void *extra, size_t delta)
|
||||
}
|
||||
p->object = new;
|
||||
|
||||
memcpy(new->data + size - delta, extra, delta);
|
||||
memcpy(new->data + new_size - delta, extra, delta);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user